I would like to sort the elements in a list by the second and third char of the elements in reverse , i.e sort by the 3rd char first and then 2nd char.
eg. If there's an array like this
array=(XA11000 XB21000 XA31000 XB12000)
The desired output of the sort would be (XA31000 XB21000 XB12000 XA11000)
It's relatively simple without the 4 digits at the end of each elements as
echo "${array[@]}"|rev | sort -r | rev
would work.
However I'm not too sure how this would work with the numbers at the end. Any suggestions?
sort ... by the second and third char of the elements in reverse , i.e sort by the 3rd char first and then 2nd char.Does this mean thesecond and third charafter reverse ignoring leading000? ...and.. your explanation of ` 3rd char first and then 2nd char` would apply without reversing?