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 #4873 from juliantaylor/masked-sort-memory

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