Draws and sorts rectangles