Speed up grid sorting by an order of magnitude.