I have no doubt that the numpy sort is superior to this algorithm.  The problem is that here we need to simultaneously sort the indices and the distances.  I benchmarked it against numpy using something along the lines of
```
i = np.argsort(dist)
ind = ind[i]
dist = dist[i]
```
and found that this cython version was consistently about twice as fast (mainly due to the fancy indexing).  If you know of a better way to do this without resorting to cython, please let me know!