1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2023-08-25 15:31:00 +08:00
parent 04aecd4abc
commit b0a97978d8
58 changed files with 1330 additions and 476 deletions

View File

@ -3,8 +3,9 @@ package maps
import (
"fmt"
"golang.org/x/exp/slices"
"slices"
"github.com/charlienet/go-mixed/expr"
xmaps "golang.org/x/exp/maps"
)
@ -124,8 +125,12 @@ func (m *sorted_map[K, V]) Asc() SortedMap[K, V] {
func (m *sorted_map[K, V]) Desc() SortedMap[K, V] {
keys := m.keys
slices.SortFunc(keys, func(a, b K) bool {
return a > b
slices.SortFunc(keys, func(a, b K) int {
if a == b {
return 0
}
return expr.Ternary(a > b, -1, 1)
})
return &sorted_map[K, V]{