Reputation: 11
This code is meant to sort integers in a csv file from high to low.
class1=open('Class1.csv','r')
csv1=csv.reader(class1, delimiter=',')
sort=sorted(csv1,key=operator.itemgetter(1))
for eachline in sort:
print (eachline)
I've seen similar examples using reverse=True
, as it is meant to sort the data in a descending order (high to low), but I can't figure out how to use it in this type of code. If you could explain where it should and why, it would be very useful, thanks.
Upvotes: 1
Views: 2957
Reputation: 42778
Put it here:
sort = sorted(csv1, key=operator.itemgetter(1), reverse=True)
Upvotes: 3