We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Thanks a lot for this, I had 100% of the idea, and got 90% of the way writing it, but the final list comprehensions had beaten me. Incidentally, I used
list.sort(key=itemgetter(0))
instead of your final lambda.
One thing - Can anyone explain why the list comprehension needs the item reference (in square brackets) for i[0] and j[0]? I don't really understand how it loops that [0] for the [0][0] in the main nested list.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Lists
You are viewing a single comment's thread. Return to all comments →
Thanks a lot for this, I had 100% of the idea, and got 90% of the way writing it, but the final list comprehensions had beaten me. Incidentally, I used
instead of your final lambda.
One thing - Can anyone explain why the list comprehension needs the item reference (in square brackets) for i[0] and j[0]? I don't really understand how it loops that [0] for the [0][0] in the main nested list.