Tag: 分拣

简单的方法来按字母顺序获得地图中的按键

在Go中,获取按照字母顺序排列的地图中的按键的最简单方法是什么? 这是我能做到的最短的方式: package main import "container/vector" import "fmt" import "sort" func main() { m := map[string]string {"b":"15", "z":"123123", "x":"sdf", "a":"12"} var keys vector.StringVector; for k,_ := range ( m ) { keys.Push(k) } sort.Sort( &keys ) fmt.Printf("%v\n", keys) }

订购一个“混合”的vector(数字与字母)

我如何订购一个像 c("7","10a","10b","10c","8","9","11c","11b","11a","12") -> alph 在 alph [1] "7","8","9","10a","10b","10c","11a","11b","11c","12" 并用它来sortingdata.frame,就像 V1 <- c("A","A","B","B","C","C","D","D","E","E") V2 <- 2:1 V3 <- alph df <- data.frame(V1,V2,V3) 并命令行获得(命令V2然后V3) V1 V2 V3 C 1 9 A 1 10a B 1 10c D 1 11b E 1 12 A 2 7 C 2 8 B 2 10b E 2 11a D 2 11c