Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 752 Bytes

InsertionSort.md

File metadata and controls

33 lines (21 loc) · 752 Bytes

Sort.InsertionSort

InsertionSort(array, [comparator], [step])

A InsertionSort algorithm

The sort maintains a sorted (left) and unsorted (right) sections. As each value is checked, if it's greater than the previous value it gets swapped to the left until it is no longer greater.

Arguments

  1. array (*[]): the input array
  2. [comparator] (Function): a function to compare 2 values *(defaults asc->desc)*
  3. [step] (Function): an optional function that gets applied at each step

Returns

(*): the sorted array