I have an array of dictionaries:
LeaderBoard = [{'Driver':'Sebastian Williams', 'Car':1, 'Team':'Red Drink','Grid':2, 'Fastest Lap':'1:37.481','Race Time':'2:27:45.958','Points':10},
{'Driver':'Tom Hamilton' ,'Car':44 ,'Team':'Mercidas' ,'Grid':6 ,'Fastest Lap':'1:37.176' ,'Race Time':'2:26:52.094' ,'Points':25 },
{'Driver':'Danny Ricardo' ,'Car':3 ,'Team':'Red Drink' ,'Grid':8 ,'Fastest Lap':'1:38.459' ,'Race Time':'2:27:38.589' ,'Points':15 },
{'Driver':'Walter Borras' ,'Car':77 ,'Team':'Lewis' ,'Grid':14 ,'Fastest Lap':'1:38.264' ,'Race Time':'2:27:22.229' ,'Points':18 },
{'Driver':'Fernando Sonal' ,'Car':14 ,'Team':'Farrori' ,'Grid':16 ,'Fastest Lap':'1:38.587' ,'Race Time':'2:27:52.040' ,'Points':8 },
{'Driver':'Jeson Smith' ,'Car':22 ,'Team':'McMilan' ,'Grid':3 ,'Fastest Lap':'1:38.284' ,'Race Time':'2:27:39.484' ,'Points':12},]
How do I sort them in order of quickest 'Race Time'?
I have tried everything I can think of. I used replace
and split
to make the race times individual numbers that I could compare easily, but I couldn't get the loops working.
This is for homework, where we need to use a sorting algorithm we have learned. Using Python's sort
or sorted
is not allowed.
No other restrictions --- any way of sorting that array of dictionaries will be fine.