refine bbox_sort logic