Sorting based on list frequency