Rob Hunter wrote: the solution was replacing <=> with cmp.
I don't understand this.
The first thing you need to do is define how EXACTLY you want things sorted. Posting an example is fine...but it is not a spec.
My guess is that you might need to break each category into components....so "1D 1" needs to be parsed into "1D" and "1". I believe that if you sort on the second part, then do another sort on the first (assuming you are using a stable sort), it will give you want you want.
There may be some tweaks needed on String vs numeric sorts, but again, without details of what you really need, it's hard to say.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors