# We will use a list of dictionary objects representing students, their classes and their current grade students = [ {'name':'Paul Allen', 'class':'Science','grade':'A'}, {'name':'paul allen', 'class':'Math','grade':'C'}, {'name':'Bob Lewis', 'class':'Science','grade':'D'}, {'name':'Bob Lewis', 'class':'math','grade':'b'}, {'name':'bob Lewis', 'class':'History','grade':'f'}, ] # Sort by class and grade descending, case sensitive ex1 = multikeysort(students, ['class', '-grade']) # Sort by class and grade descending, case insensitive from operator import itemgetter, methodcaller # Create a unary function that will get the column value and then call the .lower() method get_class = compose(itemgetter('class'), methodcaller('lower')) get_grade = compose(itemgetter('grade'), methodcaller('lower')) ex1 = multikeysort(students, ['class', '-grade'],{'class':get_class,'grade':get_grade})