<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_teachers_sorted(self):
 """Get teachers sorted by last name. This is used for the announcement request page. """

        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]))
        # Hack to return QuerySet in given order
        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