1.0.13 • Published 8 years ago

sort-all-in-one v1.0.13

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

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

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago