Filter Students 2

Consider a list of students where each student is represented by a list with two components: a (int) that is the Student Identification Number (SIN) and a list of grades in qualitative form, thus a grade is a str formed by a letter A, B, C or D possibly followed by a + or -. The order in decreasing value of qualitative grades is as follows: A+, A, A-. B+, … , D, D-.

For example:

[[77888999, ['B','A+','C-']], [22333444, ['B-','B+','A+']], [11222333, ['B','A','B+']]]

Implement the following Python function in the module filter_sts2 (file filter_sts2.py):

filter_sts2(Lsts, gref)
takes
- Lsts a non-empty list of students as specified above
- gref is a qualitative grade as specified above
returns
a list with the students in Lsts whose grades include at least one grade greater or equal than gref. The list of grades of these students will include only those grades greater or equal than gref. The list must be increasingly ordered by SIN.

Exemples:

>>> L = [[77888999, ['B', 'A-', 'C-']], [22333444, ['B-', 'B+', 'A+']], [11222333, ['B', 'A', 'B+']]]

>>> Lsol = filter_sts2(L, 'B-')
>>> Lsol == [ [11222333, ['B', 'A', 'B+']], [22333444, ['B-', 'B+', 'A+']], [77888999, ['B', 'A-']]]
True

>>> Lsol = filter_sts2(L, 'B+')
>>> Lsol == [[11222333, ['A', 'B+']], [22333444, ['B+', 'A+']], [77888999, ['A-']]]
True

>>> Lsol = filter_sts2(L, 'A+')
>>> Lsol == [ [22333444, ['A+']] ]
True

Note

To do this function you can, but is not mandatory, import and use the leq_qual(g1, g2) function provided in the module qgrades.py. Check the function code to is it useful for.

Doctests are available at the filter_sts2-test.txt file.