ENH: avoid meshgrid and fancy indexing for 1d masked sort

Improves performance by using the simple indexing path and memory by
avoiding creating a full meshgrid.
Merge pull request #4874 from juliantaylor/masked-sort-memory

ENH: avoid meshgrid and fancy indexing for 1d masked sort, for 1.9