insertionSort

Insertion sort. O(N<sup>2</sup>) time worst, average case, O(1) space, VERY small constant, which is why it's useful for sorting small subarrays in divide and conquer algorithms. If last argument is a ulong*, increments the dereference of this argument by the bubble sort distance between the input array and the sorted version of the input.

T[0]
insertionSort
(
alias compFun = "a < b"
T...
)
()
in { assert (data.length > 0); size_t len = data[0].length; foreach (array; data[1 .. $]) { static if (!is(typeof(array) == ulong*)) assert (array.length == len); } }

Meta