Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 750 Bytes

File metadata and controls

30 lines (18 loc) · 750 Bytes

Sort.InsertionSort

export function InsertionSort *(array(array, [comparator], [step])*

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 (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

(Array): the sorted array