• + 2 comments

    Many users are sorting using lambda but the problem calls for using itemgetter. My solution works but evaluates as wrong answer for test cases 10, 11 and 12. I tried copying the test case 10 input as manual test input and it worked. (:scratching-head:)

    Solution:

    def person_lister(f):
        def inner(people):
            l = [[f(people[i]), people[i][2], i] for i in range(len(people))]
            l.sort(key = operator.itemgetter(1,2))
            return [p[0] for p in l]
        return inner
    

    Test case 10 input that works as manual test input but not in the automated test:

    10
    Jake Jake 42 M
    Jake Kevin 57 M
    Jake Michael 91 M
    Kevin Jake 2 M
    Kevin Kevin 44 M
    Kevin Michael 100 M
    Michael Jake 4 M
    Michael Kevin 36 M
    Michael Michael 15 M
    Micheal Micheal 6 M