Skip to content

golang版本的BaseSearchEx sortMap函数没有起到排序的作用 #101

@youminxue

Description

@youminxue

func (s *BaseSearchEx) sortMap(mp map[int32]int) []int32 {
var newMp = make([]int, 0)
var newMpKey = make([]int32, 0)
for oldk, v := range mp {
newMp = append(newMp, v)
newMpKey = append(newMpKey, oldk)
}
sort.Ints(newMp) //排序

list := make([]int32, 0)
for k, _ := range newMp { //这里的k是下标是0到len(newMp)-1,也就是跟for k:=0;k<len(newMp);k++ {一样,上面排序没有用 
	list = append(list, newMpKey[k])
}
return list

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions