fixed ticket sorting algorithm