Skip to content

Commit 6e05620

Browse files
IntegratedQuantumandrewrk
authored andcommitted
Document the sorting order in std.sort.
1 parent ad20236 commit 6e05620

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/std/sort.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
114115
pub 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.
133135
pub 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.
233236
pub fn sort(
234237
comptime T: type,

0 commit comments

Comments
 (0)