回答編集履歴
2
参照追加
test
CHANGED
@@ -39,3 +39,13 @@
|
|
39
39
|
['acaa' 'xxx' 'vr301']]
|
40
40
|
|
41
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
参考
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
[公式ドキュメント 組込み関数 sorted](https://docs.python.org/ja/3/library/functions.html#sorted)
|
50
|
+
|
51
|
+
[NumPyのsortとargsort関数で任意の行・列を基準にソート](https://note.nkmk.me/python-numpy-sort-argsort/)
|
1
numpyの場合を追加
test
CHANGED
@@ -12,6 +12,30 @@
|
|
12
12
|
|
13
13
|
[['acac', 'xxx', 'vr101'], ['abab', 'xxx', 'vr201'], ['acaa', 'xxx', 'vr301']]
|
14
14
|
|
15
|
+
```
|
15
16
|
|
16
17
|
|
18
|
+
|
19
|
+
numpyのndarrayなら以下です。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```python
|
24
|
+
|
25
|
+
>>> print(a)
|
26
|
+
|
27
|
+
[['acaa' 'xxx' 'vr301']
|
28
|
+
|
29
|
+
['abab' 'xxx' 'vr201']
|
30
|
+
|
31
|
+
['acac' 'xxx' 'vr101']]
|
32
|
+
|
33
|
+
>>> print(a[np.argsort(a[:,2])])
|
34
|
+
|
35
|
+
[['acac' 'xxx' 'vr101']
|
36
|
+
|
37
|
+
['abab' 'xxx' 'vr201']
|
38
|
+
|
39
|
+
['acaa' 'xxx' 'vr301']]
|
40
|
+
|
17
41
|
```
|