I think _nanmedian in stats.py uses an unnecessary sort. Perhaps it is left over from a time when _nanmedian calculated the median instead of calling median.