npm.io
1.0.4 • Published 8 years ago

sorting-algos

Licence
MIT
Version
1.0.4
Deps
1
Size
6 kB
Vulns
0
Weekly
0
Stars
1

sorting-algos

implementation of various sorting algorithms in javascript

Build Status

Usage

Example

  var {bubbleSort} = require('sorting-algos')
  var {selectionSort} = require('sorting-algos')
  var {insertionSort} = require('sorting-algos')
  var {heapSort} = require('sorting-algos')
  var {mergeSort} = require('sorting-algos')
  var {quickSort} = require('sorting-algos')

  var items = [35, 13, 44, 53, 1, 34, 51, 15, 88, 42]

  console.log(bubbleSort(items))
  console.log(selectionSort(items))
  console.log(insertionSort(items))
  console.log(heapSort(items))
  console.log(mergeSort(items))
  console.log(quickSort(items))
API
var {sorter} = require('sorting-algos')

loads sorting algorithm where sorter can be bubbleSort, selectionSort, insertionSort, heapSort, mergeSort or quickSort

sorter(items)

sorts items in ascending order and returns it

License

MIT

Keywords