sort the tiles correctly