回答編集履歴

2

d

2019/10/29 06:34

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  ```python
6
6
 
7
- l = [[161, 162, 146], [57, 56, 48], [119, 119, 104], [147, 147, 132]]
7
+ l = np.array([[161, 162, 146], [57, 56, 48], [119, 119, 104], [147, 147, 132]])
8
8
 
9
9
 
10
10
 
11
11
  # 小さい順
12
12
 
13
- l.sort(key=lambda x: sum(x))
13
+ l = sorted(l, key=lambda x: sum(x))
14
14
 
15
15
  print(l)
16
16
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  # 大きい順
22
22
 
23
- l.sort(key=lambda x: sum(x), reverse=True)
23
+ l = sorted(l, key=lambda x: sum(x), reverse=True)
24
24
 
25
25
  print(l)
26
26
 

1

d

2019/10/29 06:34

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -8,10 +8,22 @@
8
8
 
9
9
 
10
10
 
11
+ # 小さい順
12
+
11
13
  l.sort(key=lambda x: sum(x))
12
14
 
13
15
  print(l)
14
16
 
15
17
  # [[57, 56, 48], [119, 119, 104], [147, 147, 132], [161, 162, 146]]
16
18
 
19
+
20
+
21
+ # 大きい順
22
+
23
+ l.sort(key=lambda x: sum(x), reverse=True)
24
+
25
+ print(l)
26
+
27
+ # [[161, 162, 146], [147, 147, 132], [119, 119, 104], [57, 56, 48]]
28
+
17
29
  ```