Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
x is not False, is always True (only in case when x == False)... it is useful in the case when 'arr' contains True/False .
For example :
sorted([1, 0, 1, 2,False, 0, 1, 3], key= lambda x: x==0)
-->[1, 1, 2, 1, 3, 0, False, 0]
but
sorted([1, 0, 1, 2,False, 0, 1, 3], key= lambda x: x==0 and x is not False)
-->[1, 1, 2, False, 1, 3, 0, 0]
Hope this helps!
Could you please explain why do we have to do it in this kata?
This comment is hidden because it contains spoiler information about the solution
Why "and x is not False"?
I tried this solution without that and it worked.
Very pythonic, not sure if sorting with this lambda is always O(n)