1
0
mirror of https://github.com/golang/go synced 2024-11-25 00:07:56 -07:00

sort: document two undocumented functions

They looked out of place in godoc.
Includes documenting sort stability.

Fixes #3356

R=golang-dev, gri, trolleriprofessorn
CC=golang-dev
https://golang.org/cl/5855044
This commit is contained in:
Brad Fitzpatrick 2012-03-20 11:40:41 -07:00
parent 1abd8d8fd0
commit 65dc7dc90b

View File

@ -183,6 +183,8 @@ func quickSort(data Interface, a, b, maxDepth int) {
} }
} }
// Sort sorts data.
// The algorithm used is not guaranteed to be a stable sort.
func Sort(data Interface) { func Sort(data Interface) {
// Switch to heapsort if depth of 2*ceil(lg(n)) is reached. // Switch to heapsort if depth of 2*ceil(lg(n)) is reached.
n := data.Len() n := data.Len()
@ -194,6 +196,7 @@ func Sort(data Interface) {
quickSort(data, 0, n, maxDepth) quickSort(data, 0, n, maxDepth)
} }
// IsSorted reports whether data is sorted.
func IsSorted(data Interface) bool { func IsSorted(data Interface) bool {
n := data.Len() n := data.Len()
for i := n - 1; i > 0; i-- { for i := n - 1; i > 0; i-- {