I have a csv file called sample.csv that I have converted into a record, this record is set up with an string value and a integer value like so:
[Name,10] [Name1,12] [Name2,14]
I would like to be able to sort these records into descending order and then eventually print the names and scores of the three highest scoring pupils and also the name and score of the lowest scoring pupil.Here is my code so far, I am unable to sort the records by integer value.
import csv file = open("sample.csv") csvreader = csv.reader(file) rows =  for row in csvreader: rows.append(row) file.close() sortedFile= sortedFile=sorted(rows, key=lambda rows: rows) print(sortedFile)
Source: Python Questions