回答編集履歴

2

my_compのreturn値の間違い修正

2019/07/11 01:33

投稿

bsdfan
bsdfan

スコア4569

test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- my_comp = lambda a, b: a[1] > b[1] if abs(a[1] - b[1]) > 0.5 else a[0] > b[0]
17
+ my_comp = lambda a, b: a[1] - b[1] if abs(a[1] - b[1]) > 0.5 else a[0] - b[0]
18
18
 
19
19
 
20
20
 

1

コードを追加

2019/07/11 01:32

投稿

bsdfan
bsdfan

スコア4569

test CHANGED
@@ -3,3 +3,21 @@
3
3
 
4
4
 
5
5
  [https://qiita.com/norioc/items/cb533d009aa63453df40](https://qiita.com/norioc/items/cb533d009aa63453df40)
6
+
7
+
8
+
9
+ ```python
10
+
11
+ import numpy as np
12
+
13
+ import functools
14
+
15
+
16
+
17
+ my_comp = lambda a, b: a[1] > b[1] if abs(a[1] - b[1]) > 0.5 else a[0] > b[0]
18
+
19
+
20
+
21
+ points = np.array(sorted(points, key=functools.cmp_to_key(my_comp))
22
+
23
+ ```