I would like to sort (shortest to longest) an array 'a' (as given below) to the distance from the origin or a point (in my case 0,0) and store it to a similar array type 'b' or replacing the array 'a'
the below given points are 3d numpy array
[[[ 510. 11.]]
[[ 651. 276.]]
[[ 269. 70.]]
[[ 920. 26.]]
[[ 513. 21.]]
[[ 1197. 620.]]
[[ 407. 268.]]
[[ 452. 35.]]
[[ 435. 3.]]
[[ 520. 20.]]
[[ 1151. 499.]]
[[ 104. 26.]]
[[ 754. 28.]]
[[ 263. 111.]]
[[ 731. 12.]]
[[ 972. 200.]]
[[ 1186. 614.]]
[[ 437. 2.]]
[[ 1096. 68.]]
[[ 997. 201.]]
[[ 1087. 200.]]
[[ 913. 201.]]
[[ 1156. 510.]]
[[ 994. 230.]]
[[ 793. 29.]]
[[ 514. 19.]]]
I cannot find any helpful information regarding these kind of 3d np arrays sorting
ps: These points 'a' were obtained from Goodfeaturestotrack ,OPEN CV ,python 3.6
and how do you clear an array to Null type ?
#this is clustering algorithm
for index in range(len(a): #a is the above matrix 3d np array
#find distance was already defined and is euclidean distance formula
if findDistance(a[index][0], a[index][1], a[index + 1][0], a[index + 1][1]) < 3: #calculation euclidean distance between ai and ai+1
c.append(index)
if findDistance(a[index][0], a[index][1], a[index + 1][0], a[index + 1][1]) > 3: #calculation euclidean distance between ai and ai+1
if len(c) > 10:
cp = np.insert(cp, c, 0)
c = [] # should clear c **is this correct ??**