From: jiahua wang Date: Tue, 21 Sep 2021 23:59:11 +0000 (+0800) Subject: sort: improve sort documentation X-Git-Tag: go1.18beta1~287 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5e59d6ebd110a7c19770c7d996930ff379ba5726;p=gostls13.git sort: improve sort documentation Fixes #48527 Change-Id: Ib5df0819cbcd5c2e4f03bda841871d237af96b19 Reviewed-on: https://go-review.googlesource.com/c/go/+/351336 Reviewed-by: Rob Pike Reviewed-by: Ian Lance Taylor --- diff --git a/src/sort/sort.go b/src/sort/sort.go index cbaa8c3aac..749310764a 100644 --- a/src/sort/sort.go +++ b/src/sort/sort.go @@ -223,7 +223,7 @@ func quickSort(data Interface, a, b, maxDepth int) { } } -// Sort sorts data. +// Sort sorts data in ascending order as determined by the Less method. // It makes one call to data.Len to determine n and O(n*log(n)) calls to // data.Less and data.Swap. The sort is not guaranteed to be stable. func Sort(data Interface) { @@ -370,7 +370,8 @@ func StringsAreSorted(x []string) bool { return IsSorted(StringSlice(x)) } // - Often "optimal" algorithms are optimal in the number of assignments // but Interface has only Swap as operation. -// Stable sorts data while keeping the original order of equal elements. +// Stable sorts data in ascending order as determined by the Less method, +// while keeping the original order of equal elements. // // It makes one call to data.Len to determine n, O(n*log(n)) calls to // data.Less and O(n*log(n)*log(n)) calls to data.Swap.