能够按键进行排序
但不能按键对的值进行排序(该操作貌似在1.0版本有效)
该问题已解决
# code
请发代码,不要发图片,我相信没人愿意给你重新敲一遍数据
我这边倒没什么问题
ps = map((x,y) -> x=>y, rand(1:100,30), rand(1:100, 30))
sort(ps, by = x->x[1]) # 按键排序
sort(ps, by = x->x[2]) # 按值排序
julia> sort(ps, by=x->x[2])
30-element Array{Pair{Int64,Int64},1}:
43 => 5
69 => 9
43 => 16
64 => 18
77 => 27
58 => 32
12 => 35
14 => 36
2 => 37
37 => 37
85 => 38
52 => 39
26 => 41
63 => 51
45 => 53
32 => 53
20 => 55
93 => 61
8 => 61
6 => 63
96 => 68
90 => 69
33 => 75
11 => 77
50 => 87
19 => 88
70 => 93
35 => 97
14 => 99
92 => 99
对于 Pair
也可以使用
ps = map((x,y) -> x=>y, rand(1:100,30), rand(1:100, 30))
sort(ps,by=x-> x.first)
sort(ps,by=x-> x.second)