gpu

module std::sortsource

Sorting in place.

Both sorts are introsorts: quicksort around a median-of-three pivot, insertion sort for ranges of 16 elements or fewer, and heapsort once the recursion is deeper than twice the length's logarithm, so the worst case stays O(n log n). Neither is stable. sort orders numbers with '<'; sort_by takes the ordering as a function and moves elements, so it sorts values owning heap memory without copying them.

fn sortsource

exp fn sort<T: Number>(values: &var [T])

Sorts the numbers in place, smallest first.

fn sort_bysource

exp fn sort_by<T>(values: &var [T], before: |&| (&T, &T) -> bool)

Sorts the values in place so that before(a, b) holds for no b placed before a; before must be a strict ordering.