Compare commits

..

No commits in common. "master" and "v1.0.0" have entirely different histories.

3 changed files with 8 additions and 27 deletions

View File

@ -28,20 +28,8 @@ maps.Values()
// GetMapsOriginMap get this maps origin data return a map[string]interface // GetMapsOriginMap get this maps origin data return a map[string]interface
maps.OriginMap() maps.OriginMap()
// SortKey sort this maps by keys asc // SortKey sort this maps by keys
maps.SortKey() 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 // other example ./maps_test.go
``` ```

View File

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

View File

@ -62,17 +62,3 @@ func TestSortKey(t *testing.T) {
fmt.Println(a) 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())
}