sort by assigning identifiers from a timetable