1 // Copyright 2015 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.
5 //go:generate go run gen.go
7 // Package internal contains non-exported functionality that are used by
8 // packages in the text repository.
9 package internal // import "golang.org/x/text/internal"
14 "golang.org/x/text/language"
17 // SortTags sorts tags in place.
18 func SortTags(tags []language.Tag) {
19 sort.Sort(sorter(tags))
22 type sorter []language.Tag
24 func (s sorter) Len() int {
28 func (s sorter) Swap(i, j int) {
29 s[i], s[j] = s[j], s[i]
32 func (s sorter) Less(i, j int) bool {
33 return s[i].String() < s[j].String()
36 // UniqueTags sorts and filters duplicate tags in place and returns a slice with
38 func UniqueTags(tags []language.Tag) []language.Tag {
44 for i := 1; i < len(tags); i++ {
45 if tags[k].String() < tags[i].String() {