1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 08:32:40 +08:00
This commit is contained in:
2022-04-22 16:36:01 +08:00
parent 6977900201
commit e06c8e3463
2 changed files with 10 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package sort
import (
"fmt"
"sort"
"strings"
)
@ -59,6 +60,12 @@ func (s *mapSorter[T]) Values() []T {
return ret
}
func (s *mapSorter[T]) String() string {
return fmt.Sprintf("map[%s]", s.Join(" ", func(k string, v T) string {
return fmt.Sprintf("%s:%v", k, v)
}))
}
func keys[T any](m map[string]T) []string {
keys := make([]string, 0, len(m))
for k := range m {