Skip to content

Commit

Permalink
build: use slices package for sorting (ethereum#27486)
Browse files Browse the repository at this point in the history
  • Loading branch information
danlaine authored and spencer-tb committed Jul 7, 2023
1 parent e7c678a commit 0e49392
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions build/update-license.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ import (
"path/filepath"
"regexp"
"runtime"
"sort"
"strconv"
"strings"
"sync"
"text/template"
"time"

"golang.org/x/exp/slices"
)

var (
Expand Down Expand Up @@ -152,13 +153,6 @@ func (i info) gpl() bool {
return false
}

// authors implements the sort.Interface for strings in case-insensitive mode.
type authors []string

func (as authors) Len() int { return len(as) }
func (as authors) Less(i, j int) bool { return strings.ToLower(as[i]) < strings.ToLower(as[j]) }
func (as authors) Swap(i, j int) { as[i], as[j] = as[j], as[i] }

func main() {
var (
files = getFiles()
Expand Down Expand Up @@ -299,7 +293,9 @@ func writeAuthors(files []string) {
}
}
// Write sorted list of authors back to the file.
sort.Sort(authors(list))
slices.SortFunc(list, func(a, b string) bool {
return strings.ToLower(a) < strings.ToLower(b)
})
content := new(bytes.Buffer)
content.WriteString(authorsFileHeader)
for _, a := range list {
Expand Down

0 comments on commit 0e49392

Please sign in to comment.