a = numpy.zeros((3, 3, 3))
a += numpy.array((1, 3, 2)).reshape((3, 1, 1))
b = numpy.arange(3 * 3 * 3).reshape((3, 3, 3))
sort_indices = numpy.argsort(a, axis=0)
static_indices = numpy.indices((3, 3, 3))
b[sort_indices, static_indices[1], static_indices[2]]
Sort a numpy array by another array, along a particular axis