multi_merge

corsort.multi_merge(xs, split_pointer_list, lt=None)[source]

Merge consecutive sorted portions of a list, two by two, in alternance.

Assume that xs[i:j] and xs[j:k] are already sorted, and merge-sort them.

Parameters:
  • xs (list) – Values to sort.

  • split_pointer_list (ndarray) – Indices of the portions (cf. example below).

  • lt (callable) – lt(x, y) is the test used to determine whether element x is lower than y. Default: operator “<”.

Examples

>>> my_xs = [2, 5, 0, 1, 7, 8, 3, 4, 6]
>>> my_split_pointer_list = np.array([0, 2, 4, 6, 9])
>>> multi_merge(my_xs, my_split_pointer_list)
>>> my_xs
[0, 1, 2, 5, 3, 4, 6, 7, 8]