sorting-javascript

1.0.5 • Public • Published

sorting-js

npm version MIT license Build Status Coverage Status dependencies Status NPM

Sorting algorithms implemented in JS

How to Install

$ npm install sorting-javascript

Getting Started

ES6 - Use named imports

  import { insertionSort } from 'sorting-javascript'
  insertionSort([7, 2, 5]) // Output - [2, 5, 7]

Node.JS require

  var sort = require('sorting-javascript')
  sort.insertionSort([7, 2, 5]) // Output - [2, 5, 7]

There is an extra utility function called ArrayTestBed which generates random numbers to test the sorting algorithms.

  import { ArrayTestBed } from 'sorting-javascript'
  const test = new ArrayTestBed(1000);
  test.setData() // test variable will have 1000 randomly generated numbers between 0-1000

By default, it will contain unique elements. If you pass random = false to the setData function, then the result will contain duplicates. eg:

  test.setData(false) // [5, 6, 6, 8, 3, 2, 2]
  test.setData() // [1, 7, 6, 8, 3, 2, 5]

List of sorting algorithms

  • Bubble sort
  • Counting sort
  • Insertion sort
  • merge sort
  • quick sort
  • selection sort

For Geeks :P

How to Test

Run one, or a combination of the following commands to lint and test your code:

$ npm run lint          # Lint the source code with ESLint 
$ npm test              # Run unit tests with Mocha 
$ npm run test:watch    # Run unit tests with Mocha, and watch files for changes 
$ npm run test:cover    # Run unit tests with code coverage by Istanbul 

To launch the documentation site, run:

$ npm install -g easystatic
$ npm start

License

MIT © 2016 Neelesh Roy

Readme

Keywords

none

Package Sidebar

Install

npm i sorting-javascript

Weekly Downloads

11

Version

1.0.5

License

MIT

Unpacked Size

57.6 kB

Total Files

14

Last publish

Collaborators

  • neeleshroy