Sort function for items added