1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 "golang.org/x/text/collate"
12 "golang.org/x/text/language"
15 func ExampleCollator_Strings() {
16 c := collate.New(language.Und)
23 c.SortStrings(strings)
25 // Output: [ab äb ac ad]
30 func (s sorter) Len() int {
34 func (s sorter) Swap(i, j int) {
35 s[j], s[i] = s[i], s[j]
38 func (s sorter) Bytes(i int) []byte {
42 func TestSort(t *testing.T) {
43 c := collate.New(language.English)
49 c.Sort(sorter(strings))
50 res := fmt.Sprint(strings)
51 want := "[abc bcd ddd]"
53 t.Errorf("found %s; want %s", res, want)