authorgravatar for jahe788@gmail.comIntegratedQuantum <jahe788@gmail.com> 2023-05-17 17:20:21+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-17 18:26:49-07:00
log6e05620117e4bae98dc5fac2fbc1b81aa7ad17c4
tree42c924c4de0b0a4db03a431fec2192538a41c6c3
parentad20236e977cf6e55f2da1340952e521e2507786

Document the sorting order in `std.sort`.


1 files changed, 3 insertions(+), 0 deletions(-)

lib/std/sort.zig+3
......@@ -109,6 +109,7 @@ test "binarySearch" {
109109
110110/// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case.
111111/// O(1) memory (no allocator required).
112/// Sorts in ascending order with respect to the given `lessThan` function.
112113/// This can be expressed in terms of `insertionSortContext` but the glue
113114/// code is slightly longer than the direct implementation.
114115pub fn insertionSort(
......@@ -130,6 +131,7 @@ pub fn insertionSort(
130131
131132/// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case.
132133/// O(1) memory (no allocator required).
134/// Sorts in ascending order with respect to the given `context.lessThan` function.
133135pub fn insertionSortContext(len: usize, context: anytype) void {
134136 var i: usize = 1;
135137 while (i < len) : (i += 1) {
......@@ -229,6 +231,7 @@ const Pull = struct {
229231
230232/// Stable in-place sort. O(n) best case, O(n*log(n)) worst case and average case.
231233/// O(1) memory (no allocator required).
234/// Sorts in ascending order with respect to the given `lessThan` function.
232235/// Currently implemented as block sort.
233236pub fn sort(
234237 comptime T: type,