I am in the process of writing some code to generate graphs/metrics for climbing logs my friends and family have kept over the years. One problem I am running into relates to sorting of Yosemite climbing grades.
Running the following code:
testlist = ["5.10a", "5.5", "5.8+", "5.11b", "5.6"]
sortedtestlist = sorted(testlist)
print(sortedtestlist)
Results in:
['5.10a', '5.11b', '5.5', '5.6', '5.8+']
5.5 should occur before 5.10a. It appears that sorted is only looking at a depth of one number? I stripped the "5." out of the grades, sorted, and re-added them later and I got the same behavior.
The results I am trying to get are:
['5.5', '5.6', '5.8+', '5.10a', '5.11b']
I know if it comes down to it, I can probably write my own sorting function and past that to sorted. Is there an easier way?