when I sort by first and second element in the list(tuple), it works, but sorting by third element is not working any more the input:
mylist=[('11', '82075.36', '8.15'), ('16', '82073.78', '12.92'), ('13', '62077.99', '17.89'),]
the request:
print(sorted(mylist, key=lambda val: val[0]))
print(sorted(mylist, key=lambda val: val[1]))
print(sorted(mylist, key=lambda val: val[2]))
and the output:
[('11', '82075.36', '8.15'), ('13', '62077.99', '17.89'), ('16', '82073.78', '12.92')] # it is OK
[('13', '62077.99', '17.89'), ('16', '82073.78', '12.92'), ('11', '82075.36', '8.15')] # it is OK`
[('16', '82073.78', '12.92'), ('13', '62077.99', '17.89'), ('11', '82075.36', '8.15')] # this seems to be not correct, can anybody explain why?
if I remove the quotes from the third elm it works, anyhow, for elm 1 it works without removing the quotes
mylist=[('11', '82075.36', 8.15), ('16', '82073.78', 12.92), ('13', '62077.99', 17.89),]
and the output:
[('11', '82075.36', 8.15), ('16', '82073.78', 12.92), ('13', '62077.99', 17.89)]