sort_items helper