1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
Files
go-mixed/sort/sort_test.go
2022-04-22 16:36:01 +08:00

46 lines
665 B
Go

package sort
import (
"fmt"
"testing"
)
func TestSort(t *testing.T) {
m := map[string]any{
"Bcd": "bcd",
"Abc": "abc",
}
t.Log(SortByKey(m).Values())
t.Log(SortByKey(m).Desc().Values())
t.Log(SortByKey(m).Asc().Values())
}
func TestMapSortInt(t *testing.T) {
m := map[string]int{
"Bcd": 8,
"Abc": 4,
}
ret := SortByKey(m).Desc().Values()
t.Log(SortByKey(m).Desc())
t.Log(SortByKey(m).Asc())
t.Log(ret)
}
func TestJoin(t *testing.T) {
m := map[string]any{
"Bcd": "bcd",
"Abc": "abc",
"Efg": "efg",
}
t.Log(m)
j := SortByKey(m).Asc().Join("&", func(k string, v any) string {
return fmt.Sprintf("%s=%v", k, v)
})
t.Log(j)
}