Sort final output by coordinate.