(Feb-10-2021, 11:26 AM)Fernando_7obink Wrote: about the 'str' in key ... how does it work ? does it mean the key = str will take each element and change them to str type data and compare them ?yes, I think it's pretty clear from the docs I quoted in my answer. It will apply function supplied as key on each element in the list and use the result to compare/order the element, in this case the function is
str()
- a built-in function, in the @Gribouillis example - a lambda function (that is anonymous function) which takes one argument klass
(i.e. one element) and returns klass.__name__
attribute (which is also a string).
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs