Sort the climbing grades
Python 2, 58 54 bytes
lambda x:sorted(x,key=lambda y,B10=0:eval(y[1:]+'10'))
Try it online!
How it works
y y[1:]+'10' eval(y[1:]+'10')
=======================================
VB B10 0 (a variable we defined)
V0 010 8 (an octal literal)
V0+ 0+10 10
V1 110 110
V2 210 210
... ... ...
V17 1710 1710
JavaScript (ES6) / Firefox, 53 bytes
a=>a.sort((a,b)=>(g=s=>parseInt(s,32)%334+s)(a)>g(b))
Test cases
For Firefox:
let f =
a=>a.sort((a,b)=>(g=s=>parseInt(s,32)%334+s)(a)>g(b))
console.log(JSON.stringify(f([])))
console.log(JSON.stringify(f(['V1'])))
console.log(JSON.stringify(f(['V7', 'V12', 'V1'])))
console.log(JSON.stringify(f(['V13', 'V14', 'VB', 'V0'])))
console.log(JSON.stringify(f(['V0+', 'V0', 'V16', 'V2', 'VB', 'V6'])))
For Chrome or Edge (+4 bytes):
let f =
a=>a.sort((a,b)=>(g=s=>parseInt(s,32)%334+s)(a)>g(b)||-1)
console.log(JSON.stringify(f([])))
console.log(JSON.stringify(f(['V1'])))
console.log(JSON.stringify(f(['V7', 'V12', 'V1'])))
console.log(JSON.stringify(f(['V13', 'V14', 'VB', 'V0'])))
console.log(JSON.stringify(f(['V0+', 'V0', 'V16', 'V2', 'VB', 'V6'])))
How?
We apply 3 successive transformations that lead to lexicographically comparable strings.
s | Base32 -> dec. | MOD 334 | +s
------+----------------+---------+---------
"VB" | 1003 | 1 | "1VB"
"V0" | 992 | 324 | "324V0"
"V0+" | 992 | 324 | "324V0+"
"V1" | 993 | 325 | "325V1"
"V2" | 994 | 326 | "326V2"
"V3" | 995 | 327 | "327V3"
"V4" | 996 | 328 | "328V4"
"V5" | 997 | 329 | "329V5"
"V6" | 998 | 330 | "330V6"
"V7" | 999 | 331 | "331V7"
"V8" | 1000 | 332 | "332V8"
"V9" | 1001 | 333 | "333V9"
"V10" | 31776 | 46 | "46V10"
"V11" | 31777 | 47 | "47V11"
"V12" | 31778 | 48 | "48V12"
"V13" | 31779 | 49 | "49V13"
"V14" | 31780 | 50 | "50V14"
"V15" | 31781 | 51 | "51V15"
"V16" | 31782 | 52 | "52V16"
"V17" | 31783 | 53 | "53V17"
Husk, 5 bytes
ÖiÖm±
Try it online! The results are printed one per line, but internally this is a function that takes and returns a list of strings.
Explanation
This is surprisingly similar to Martin's Retina answer.
First we do Öm±
, meaning "order by mapping is-digit".
This puts VB
, V0
and V0+
in the correct order, since they are compared as [0,0]
, [0,1]
and [0,1,0]
.
Next we do Öi
, meaning "order by integer value".
Given a string, i
returns the first sequence of digits occurring in it as an integer, or 0 if one is not found.
The three strings above are all mapped to 0 and the sort is stable, so they will be in the correct order in the output.