corrected sorting for items