I need to sort an array of alphanumeric elements as follows. From:
2 xxx 20 axxx 38 xxxx 20 bx 8540 xxxxxx
in
8540 xxxxx 38 xxxx 20 axxx 20 bx 2 xxx
Thus, sorted in descending order with respect to numbers, then in ascending order in alphabetical order. Numbers are always separated from alphabetic characters (denoted by "xxxx") by a single space, but numbers are of variable length.
I suspect that I need to use some kind of Regex in the sort () function and separate the numbers with a space and then sort it, but I donβt know how to link it in alphabetical order. Any code examples? Thank you very much!
source share