An array to be sorted has strings such as:
200burgers
1apple
2burgers
11apples
and similar. When sorting ascendingly with caseInsenstive, I get:
11apples
1apple
200burgers
2burgers
Which makes sense, but I would prefer a lexicographical sort that put “1” before “10”, “10” before “100”, &c., such as:
1apple
11apples
2burgers
200burgers
Must I construct a custom comparator or is there some other option?
I think you’ll probably need a custom comparator, but it’d be something really simple: