@bemoje/arr-insertion-sort-numeric

1.0.1 • Public • Published

@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

NPM version

Travis CI

dependencies

Dependencies

dependencies

Stats

NPM downloads Forks

Donate

Buy Me A Beer donate button PayPal donate button

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

Package Sidebar

Install

npm i @bemoje/arr-insertion-sort-numeric

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

9.78 kB

Total Files

5

Last publish

Collaborators

  • bemoje