Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sort-all-in-one

OnlyRefat16ISC1.0.13

A Lite(20KB) sorting package that gives the option to the array of objects to sort with several alogithms based on any key of that objects

sort, sorting, object sorting, bubble, quick, merge, insertion, selection, collection sorting, array of object sorting

readme

sort-all-in-one

A lite, tinny package that is less than 20 KB in size.

Dependencies:

momentjs

Overview:

A sorting package that gives the option to sort array of objects sort with several alogithms based on any key of that objects. currently we are offering the several algorithms

  • Bubble Sort
  • Selection Sort
  • Merge Sort
  • Quick Sort
  • Insertion Sort

Features:

  • Collection sorting (array of objects)
  • Based on Any key
  • Date type key based sorting

Installation:

npm install sort-all-in-one

Usage:

const languages = [
  {
    name: 'C',
    year: 1972
  },
  {
    name: 'C#',
    year: 2000
  },
  {
    name: 'C++',
    year: 1983
  },
  {
    name: 'Clojure',
    year: 2007
  },
  {
    name: 'Elm',
    year: 2012
  },
  {
    name: 'Go',
    year: 2009
  }
];

If you want to sort the array of objects based on its key name or based on its key year

let opts = {
  algo: 'default',    // bubble,selection,insertion,quick,merge
  array: languages,
  key: 'year',
  orderBy: 'desc',      // asc,desc
  date: true,          // if the key is a date or false if not
},

const Sorting = new NpmSorting();
const sortedList = Sorting.sort(opts);

If you want to fetch the number of comparisons done in sorting the data just use compareCount() method. Example Code:

let opts = {
  algo: 'default',    // bubble,selection,insertion,quick,merge
  array: languages,
  key: 'year',
  orderBy: 'desc',      // asc,desc
  date: true,          // if the key is a date or false if not
},

const Sorting = new NpmSorting();
const sortedList = Sorting.sort(opts);
const count = Sorting.compareCount();

Demo

Coming Soon

Contributer

The original author is Rafi Ud Daula Refat and Mashuk Sadman