Someone posted a solution on HackerRank to a sorting problem. The challenge is simple, return a sorted string in this order: lowercase, uppercase, odd nums, even nums, and the solution looks like:
abc = sorted(instring, key=lambda c: (-ord(c) >> 5, c in '02468', c))
I don't understand how the syntax in the lambda works. It seems the lambda is returning a tuple, but how is that being interpreted as the key for the sort? At first I thought maybe it was an alternative syntax for the ternary operator, but it just returns the tuple.
How does this work?