Skip to content

Commit

Permalink
sort: improve sort documentation
Browse files Browse the repository at this point in the history
Fixes #48527

Change-Id: Ib5df0819cbcd5c2e4f03bda841871d237af96b19
Reviewed-on: https://go-review.googlesource.com/c/go/+/351336
Reviewed-by: Rob Pike <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
180909 authored and ianlancetaylor committed Nov 16, 2021
1 parent f659183 commit 5e59d6e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sort/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5e59d6e

Please sign in to comment.