I got a problem regarding sorting a list within Python. For some reason it does rank the list on the highest value but after that process is done, other elements within that list are not sorted anymore.
My code:
import csv
id_list = []
with open('source/to/file/output.csv', 'rt') as f:
reader = csv.reader(f, delimiter=',', quotechar='"')
for row in reader:
test = "177"
if test == row[0]:
id_list.append([row[2],row[1]])
generated_list = id_list[0], id_list[16], id_list[20]
print(generated_list)
print(sorted(generated_list))
The result of the print is:
-- (['17', '179'], ['5', '2641'], ['9', '3705']) # not sorted
-- [['17', '179'], ['5', '2641'], ['9', '3705']] # sorted
What I would expect is that the sorting method will output:
-- [['17', '179'], ['9', '3705'], ['5', '2641']] # sorted
Am I doing something wrong?