npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sugar-sorting

v0.0.7

Published

Sorting made sweet.

Downloads

34

Readme

Build Status Coverage Status

Sugar-sorting

Sorting made sweet.

NPM

What is sugar-sorting?

Sugar-sorting is a NPM Module for sorting arrays. It's main goal is to provide a simple sorting API and many different sorting methods for the user to choose from. Sugar-sorting can make it easy for you to sort simple arrays and arrays of objects.

Getting Started

The first thing you should do is install the sugar-sorting module.

$ npm install -g sugar-sorting

Now you can use require() to assign this module to a variable and start calling the module's methods.

var Sorter = require('sugar-sorting');

var simpleArray = [2, 4, 6, 3, 1, 5];
var sorter = new Sorter(simpleArray);

console.log(sorter.bubbleSort());
// --> [1, 2, 3, 4, 5, 6]

Sorting Arrays of Objects

Sugar-sorting also makes it easier for you to sort your arrays of objects by any property you want to. You just need to call the sortBy('.propertyPath') method.

var Sorter = require('sugar-sorting');

var students = [{
    name: 'Stanley Kubrick',
    age: 50,
    grades: {
      highestGrade: 10,
      lowestGrade: 8
    }
  }, {
    name: 'Christopher Nolan',
    age: 31,
    grades: {
      highestGrade: 8.5,
      lowestGrade: 6
    }
  }, {
      name: 'Michael Bay',
      age: 37,
      grades: {
        highestGrade: 2,
        lowestGrade: 0
      }
  }];

var studentsSorter = new Sorter(students);

var studentsByAge = studentsSorter.sortBy('.age').insertionSort();
var studentsByHighestGrade = studentsSorter.sortBy('.grades.highestGrade').bubbleSort();

Sorting methods

These are the sorting methods on sugar-sorting. The ones marked with an X are the ones available for use.

  • [x] bubbleSort()
  • [x] selectionSort()
  • [x] insertionSort()
  • [x] mergeSort()
  • [x] heapSort()
  • [x] quickSort()
  • [ ] shellSort()

If you want to learn more about sorting algorithms and the best and worst case scenarios for each one, you can check these amazing links:

  • http://sorting.at
  • http://sorting-algorithms.com

How sugar-sorting Works

When using sugar-sorting, imagine the Sorter object as a magic box in which you put in your array and then tell the box the way you want it to be sorted. After telling the box what you want it will sort your array. Now all you need to do is get the new sorted array from inside the box.

These are some basic steps to follow:

  • Fill your sorter object using var sorter = new Sorter(yourArray) or sorter.fillWith(yourArray)
  • Tell the sorter object how you want it to be sorted. For example: sorter.sortBy('.salary').heapSort()
  • Retrieve the sorted array from the sorter object using sorter.getElements()

Contributing

You can contribute to sugar-sorting by writing tests, improving our algorithms or even creating new ones. Any improvement on the project's docs are welcome too!

To start developing just clone this repository and run the npm install command on your terminal to download all the dev-dependencies.

If you find any bug or have any suggestion please tell us using our Issue Tracker.

After changing any line of code please run tests using npm test or grunt.

License

Use it as you want to. No worries.

MIT © Lucas Fernandes da Costa