I have a 2D array list that contains (x,y), however I want to sort this list by the Equation of Minimum value of (square root of (x^2 + y^2)).
For example I have these four 2D lists:
(20,10)
(3,4)
(5,6)
(1.2,7)
If I take the square root of each 2D array in this list and return the minimum of the sorted list, the output is:
(3,4)
(1.2,7)
(6.5,4)
(5,6)
(20,10)
the Code :
M=[ [20,10],[3,4],[5,6],[1.2,7],[6.5,4]]
s=np.sqrt(M)
a=[]
print s
for i in range(0,h):
for j in range(0,w):
a[i] =s[i][j]+a[i]
Any ideas?