functions: Use slices package for sorting
From Go 1.21 release notes[1]: New slices package for common operations on slices of any element type. This includes sorting functions that are generally faster and more ergonomic than the sort package. [1]: https://go.dev/blog/go1.21
This commit is contained in:
parent
164e30b37d
commit
057b2e15f6
1 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import "sort"
|
||||
import (
|
||||
"slices"
|
||||
)
|
||||
|
||||
func sortKeys(m map[string]string) []string {
|
||||
var s []string
|
||||
|
@ -8,6 +10,6 @@ func sortKeys(m map[string]string) []string {
|
|||
s = append(s, key)
|
||||
}
|
||||
|
||||
sort.Strings(s)
|
||||
slices.Sort(s)
|
||||
return s
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue