I have a text file whose contents are directory listing output, like this:
A normal sort will put these three lines in the order shown. A simple reverse sort will replace 1-2-3 with 3-2-1. But what I want is for them to be sorted in alphabetical order, but starting with the last character in the filename. In that case, they would be resorted from 1-2-3 to 2-3-1, because their last letters are o, t, and d, respectively.
In case of a tie, I want to progress backward along the filename, looking at character (end-1) and then (end-2) and so forth as needed. So a filename ending with aaa would come before a file ending with aba.
Can it be done in bash, or with some other easy-to-learn (as in minutes, not hours) Ubuntu tool?