@bemoje/arr-insertion-sort-numeric
v1.0.1
Published
Sorting by insertion - Look for bigger numbers on the left side. Runtime: O(n^2). It starts from the 2nd element, and it tries to find any element (to the left) that could be bigger than the current index. It will move all the elements that are bigger and
Downloads
11
Maintainers
Readme
@bemoje/arr-insertion-sort-numeric
Sorting by insertion - Look for bigger numbers on the left side. Runtime: O(n^2). It starts from the 2nd element, and it tries to find any element (to the left) that could be bigger than the current index. It will move all the elements that are bigger and insert the current element where it belongs.
Version
Travis CI
Dependencies
Stats
Donate
Installation
npm install @bemoje/arr-insertion-sort-numeric
npm install --save @bemoje/arr-insertion-sort-numeric
npm install --save-dev @bemoje/arr-insertion-sort-numeric
Usage
import arrInsertionSortNumeric from '@bemoje/arr-insertion-sort-numeric'
arrInsertionSortNumeric([0, 2, 1])
//=> [0, 1, 2]
arrInsertionSortNumeric([])
//=> []
Tests
Uses Jest to test module functionality. Run tests to get coverage details.
npm run test
API
arrInsertionSortNumeric
Sorting by insertion - Look for bigger numbers on the left side. Runtime: O(n^2). It starts from the 2nd element, and it tries to find any element (to the left) that could be bigger than the current index. It will move all the elements that are bigger and insert the current element where it belongs.
Parameters
arr
Array The array to sort
Returns
Array The sorted array