code: def get_teachers_sorted(self):
          teachers = self.get_teachers()
          teachers = [(u.last_name, u.first_name, u.id) for u in teachers]
          for t in teachers:
              if t is None or t[0] is None or t[1] is None or t[2] is None:
                  teachers.remove(t)
          for t in teachers:
              if t[0] is None or len(t[0]) <= 1:
                  teachers.remove(t)
          teachers.sort(key=lambda u: (u[0], u[1]))
          id_list = [t[2] for t in teachers]
          clauses = ' '.join(['WHEN id=%s THEN %s' % (pk, i) for i, pk in enumerate(id_list)])
          ordering = 'CASE %s END' % clauses
          queryset = User.objects.filter(id__in=id_list).extra(select={'ordering': ordering}, order_by=('ordering',))
          return queryset