Python: sorting an array with another array's elements as keys? -


import numpy np x = np.array(range(10 * 30)).reshape(100, 3) y = np.array(range(1010, 10, -10)) res = sorted(x, key = lambda y:y) #valueerror: truth value of array more 1 element ambiguous. use a.any() or a.all() res = sorted(x, key=y) #typeerror: 'tuple' object not callable 

try argsort:

import numpy np x = np.array(range(10 * 30)).reshape(100, 3) y = np.array(range(1010, 10, -10)) args = y.argsort(axis = 0) print x[args] 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -