added sorting of allocated rects