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.
It trades performance for readability though. Performance is quite suboptimal.
I like this approach. Looks very interesting
THAT IS SO COOL! I NEVER KNEW THIS! BUT NOW I DO! MUAHAHAH
A huge thank you to you YesLod!!! Now I get it. Much appreciated!
When you pass a function, f, to the key parameter, the elements of the iterable are sorted according to the returned value of that function and not their own value. Basically, the function receives one argument (each element) and maps it to a given value which is used only for establishing the order between elements. This means that for instance e1>e2 if f[e1]>f[e2].
In this case, the returned value of the function (x >= k) is a boolean, and therefore the function maps the elements either to 0 (False), if x<k , or 1 (True) if x>=k. All elements less than k (value 0) will be placed before the elements greater or equal to k (value 1) since 0 < 1.
Note that the original order in the list is still preserved for elements mapped to the same value because they are “equivalent under the function”, and therefore don’t switch position with each other when compared.
could anybody explain this code please? I don't understand the way lambda sorts the list..