I need to sort a list of strings.
However, I do not want to sort it using the first character, so I cannot use .sort()
I have a list:
records = ["Bibble - 1300 / 2000",
"Jim Foo - 900 / 2000",
"Bibble - 1600 / 2000",
"Bibble - 1000 / 2000"]
I want to sort by their score out of 2000. I want an output that looks something like this:
>>> Jim Foo - 900 / 2000
Bibble - 1000 / 2000
Bibble - 1300 / 2000
Bibble - 1600 / 2000
In the example above, I sorted it by smallest to largest. I also want to know how I would sort this list biggest score to smallest score.
I've tried .sort(), but It's nothing like what I want. .sort() sorts it with the first character which I do not want:
>>> records.sort()
>>> records
['Bibble - 1000 / 2000', 'Bibble - 1300 / 2000', 'Bibble - 1600 / 2000', 'Jim Foo - 900 / 2000']
>>>
Is there anyway of doing this, possibly in regular expression?
Is it also possible, so if i were to add more scores into the list I would still be able to sort it this way?
keywhen you callsort.