]> Cypherpunks repositories - gostls13.git/commitdiff
sort: add example for Strings
authorTony Walker <walkert.uk@gmail.com>
Sat, 15 Jul 2017 22:27:29 +0000 (22:27 +0000)
committerBryan Mills <bcmills@google.com>
Sat, 15 Jul 2017 23:17:23 +0000 (23:17 +0000)
Change-Id: I33f0e2362e85287b493d9279d43b760733e2abcb
Reviewed-on: https://go-review.googlesource.com/48831
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/sort/example_test.go

index 89ebe790c1cbf21a760214738f93c4dabf777d20..f8d8491bc4c75aecca6bfb2e2750056ca137e64b 100644 (file)
@@ -69,3 +69,10 @@ func ExampleSliceStable() {
        // Output: By name: [{Alice 25} {Alice 75} {Alice 75} {Bob 75} {Bob 25} {Colin 25} {Elizabeth 75} {Elizabeth 25}]
        // By age,name: [{Alice 25} {Bob 25} {Colin 25} {Elizabeth 25} {Alice 75} {Alice 75} {Bob 75} {Elizabeth 75}]
 }
+
+func ExampleStrings() {
+       s := []string{"Go", "Bravo", "Gopher", "Alpha", "Grin", "Delta"}
+       sort.Strings(s)
+       fmt.Println(s)
+       // Output: [Alpha Bravo Delta Go Gopher Grin]
+}