I have an array of strings, each element contains two or three numbers, one space and one letter.
array = [ "293 C",
"401 B","421 B","428 B","439 B","315 C","529 B","560 B","566 B",
"567 B","616 B","39 C","28 C","30 C","698 B","719 B","722 B",
"640 B","786 B","645 B","236 B","255 B","442 C","446 C","477 C",
"368 C","381 C","399 C","406 C","504 C","505 C","515 C","116 C",
"138 C","147 C","174 C"]
What I need as a result is something like this.
["236 B","255 B","401 B","421 B","428 B","439 B","529 B","560 B",
"566 B","567 B","616 B","640 B","645 B","698 B","719 B","722 B",
"786 B","28 C","30 C", "39 C","116 C","138 C","147 C","174 C", "293 C",
"315 C", "368 C", "381 C","399 C","406 C","442 C","446 C",
"477 C","504 C","505 C","515 C"]
In other words, I need to sort the list of strings using the letter suffix as the major sort key, and the integer value of the digit prefix as the minor key.
I've tried with sort_by method, but it only allows me to sort the array by the letter (if I split each element first)