]> Cypherpunks repositories - gostls13.git/commitdiff
sort: add time complexity to doc
authorStefan Nilsson <snilsson@nada.kth.se>
Thu, 22 Mar 2012 16:27:02 +0000 (09:27 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 22 Mar 2012 16:27:02 +0000 (09:27 -0700)
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

src/pkg/sort/sort.go

index ca715645af4af2a404874b327f1046987dfacace..62a4d55e798477ed6c71d3fb3778bda4f89ab394 100644 (file)
@@ -184,7 +184,8 @@ func quickSort(data Interface, a, b, maxDepth int) {
 }
 
 // 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) {
        // Switch to heapsort if depth of 2*ceil(lg(n+1)) is reached.
        n := data.Len()