lambda is the key function that is applied to each member of rows in order to sort rows. So x is a single row.
x[-1] is the last element in the row. python allows to use negative indexes.
[:-1] is slicing notation. it will return everything, by the last char of the last element
you can read https://docs.python.org/3/tutorial/intro...ml#strings
x[-1] is the last element in the row. python allows to use negative indexes.
[:-1] is slicing notation. it will return everything, by the last char of the last element
you can read https://docs.python.org/3/tutorial/intro...ml#strings
>>> x = (33011907.77726958, 'Vancito E.', 'Gumbs SR', 'Vancito E. Gumbs SR', 'ABCDE1') >>> x[-1] 'ABCDE1' >>> x[-1][:-1] 'ABCDE' >>>Now when I think, given that last char is always the same for all elements in a given group, it can be just
for row in sorted(rows, key=lambda x: x[-1]):
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