Commit 08959def authored by Stefan Nilsson's avatar Stefan Nilsson Committed by Robert Griesemer

sort: add time complexity to doc

Let's tell the world that Go's sort is O(n log n).
Surely this is a feature we intend to keep.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5867045
parent 2795a15c
...@@ -184,7 +184,8 @@ func quickSort(data Interface, a, b, maxDepth int) { ...@@ -184,7 +184,8 @@ func quickSort(data Interface, a, b, maxDepth int) {
} }
// Sort sorts data. // Sort sorts data.
// The algorithm used is not guaranteed to be a stable sort. // 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) { func Sort(data Interface) {
// Switch to heapsort if depth of 2*ceil(lg(n+1)) is reached. // Switch to heapsort if depth of 2*ceil(lg(n+1)) is reached.
n := data.Len() n := data.Len()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment