📝 更新测试文档

This commit is contained in:
coward 2021-12-03 16:16:00 +08:00
parent c8923b6bf1
commit db26c97e7b
3 changed files with 27 additions and 8 deletions

View File

@ -28,8 +28,20 @@ maps.Values()
// GetMapsOriginMap get this maps origin data return a map[string]interface
maps.OriginMap()
// SortKey sort this maps by keys
// SortKey sort this maps by keys asc
maps.SortKey()
// other sort
// sort by desc
sort.Slice(maps.Keys,func (i,j int) bool {
return maps.Keys()[i] > maps.Keys()[j]
})
// sort by asc
sort.Slice(maps.Keys,func (i,j int) bool {
return maps.Keys()[i] < maps.Keys()[j]
})
// other example ./maps_test.go
```

View File

@ -5,13 +5,6 @@ import (
"sync"
)
const (
// SortAsc sort by asc
SortAsc = "asc"
// SortDesc sort by desc
SortDesc = "desc"
)
type maps struct {
rw sync.RWMutex
Key []string

View File

@ -62,3 +62,17 @@ func TestSortKey(t *testing.T) {
fmt.Println(a)
}
func TestSort(t *testing.T) {
maps := NewMaps()
a := maps.Set("key3", "value1").Set("key4", "value 2").Set("key1", "value 3")
sort.Slice(a.Keys(), func(i, j int) bool {
return a.Keys()[i] > a.Keys()[j]
})
fmt.Println(a.Keys())
fmt.Println(a.Values())
fmt.Println(a.OriginMap())
}