Try not to utilize lambda functions when there are built-in ones for the work. Additionally, never utilize the cmp arguments of sorted, the reason is that it's deplored:
But, that won't keep "A" & "a" in order, so:
that will and, by the idea of sorted the activity will be extremely quick for nearly sorted list (the second arranged).
Are you Interested in learning the concepts of python? Join python online course.