Sorting in teacher index and student index