回答編集履歴
1
追記
test
CHANGED
@@ -37,3 +37,23 @@
|
|
37
37
|
[https://docs.python.jp/3/library/stdtypes.html#dict.items](https://docs.python.jp/3/library/stdtypes.html#dict.items)
|
38
38
|
|
39
39
|
[https://docs.python.jp/3/library/functions.html#zip](https://docs.python.jp/3/library/functions.html#zip) の下の方のコード例
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
1行にまとめるとこう。
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
>>> dic = {'a':1,'c':2,'d':3,'b':4}
|
48
|
+
|
49
|
+
>>> dic_keys, dic_values = zip(*sorted(dic.items()))
|
50
|
+
|
51
|
+
>>> dic_keys
|
52
|
+
|
53
|
+
('a', 'b', 'c', 'd')
|
54
|
+
|
55
|
+
>>> dic_values
|
56
|
+
|
57
|
+
(1, 4, 2, 3)
|
58
|
+
|
59
|
+
```
|