1.0.0 • Published 4 years ago

@andreas-h/array-sort v1.0.0

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

@andreas-h/array-sort

A package containing many different sorting algorithms for sorting arrays.

Getting Started

Prerequisites

The latest version of npm or yarn

Installing

npm i @andreas-h/array-sort
bower install @andreas-h/array-sort
yarn add @andreas-h/array-sort

Usage

const sort = require('.@andreas-h/array-sort/array-sort.js');

let sortedArr = sort.introSort([2,4,1,3,5]);
console.log(sortedArr);
//Output [1,2,3,4,5]

let sortedArrAsc = sort.cocktailSort([2,4,1,3,5],'asc');
console.log(sortedArrAsc);
//Output [5,4,3,2,1]

let stringSort = sort.mergeSort(['b','c','a']);
console.log(stringSort);
//Output ['a','b','c'];

List of current sorting algorithms implemented

  • Comparison sorts

    • Bubble
    • Bingo
    • Comb
    • Cycle
    • Cocktail
    • Gnome
    • (max) Heap
    • (min) Heap
    • Insertion
    • (Binary) Insertion
    • Introspective
    • Merge
    • Odd even
    • Patience
    • Quick
    • (double) Selection
    • Selection
    • Shell
    • Tim
  • Non-comparison sorts

    • Bucket
    • Counting
    • Flash
    • (LSD) Radix
    • Pigeonhole
  • Other
    • Bogo
    • Gravity
    • Stooge

List of current helper functions implemented

  • Binary search
  • Execution time for functions or sorting methods
  • Get max element index
  • Get position of a number
  • (min) Heapify
  • (max) Heapify
  • Partition operation
  • Random array creater
  • Swap array elements

References

Author

License

This project is licensed under the ISC License - see the LICENSE.md file for details