Skip to content

OnlyRefat/sort-all-in-one

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 we 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published