I've got the following code:
cases = []
for file in files:
# Get value from files and write to data
data = [ id, b, c, d, e, f, g, h, i, j, k ]
# Append the values to the data list
cases.append(data)
# Sort the cases descending
cases.sort(reverse=True)
After running the for loop the cases list looks like this:
cases = [ ['id', val, val], ['id', val, val], ['id', val, val] ] etc.
id is a value like '600', '900', '1009', '1009a' or '1010' which I want to sort descending.
At the moment '1009a' is on top of the list while I want it to be between '1009' and '1010'. This is probably related to '1009a' being parsed as unicode while the other values are being parsed as long. A debugger also confirms this.
I've tried converting the id field to unicode using unicode(id) while writing the data list, but this does not give the desired result either. After sorting cases, output will start at '999', until reaching '600' and then will start at '1130' and run down to '1000'. Instead of starting at '1130' and running down to '600'. Which is what i want, with '1009a' being between '1009' and '1010'.
unicode(id)), but you haven't shown it in any sort of detail, so we can't really help you fix it.