File ordering by portion of filename

Hi,

Lets say I have a few xml files:
1234567894.xml
abc_1234567895.xml
abc_000_1234567890.xml
abc_0000000_1234567893.xml
684_abc_000_1234567899.xml

The naming convention of the files is:
xxxxx_timestamp.xml OR timestamp.xml
where x can be anything

and I would like to order them by the timestamp, so the list should be:

abc_000_1234567890.xml
abc_0000000_1234567893.xml
1234567894.xml
abc_1234567895.xml
684_abc_000_1234567899.xml

Is there anyway to order the files using the ls command?
or do I need to use awk for this?

if the timestamp in the filename corresponds to the actual timestamp when file is "created", then you can use ls -lt. Otherwise, use it together with sort.

Hi, unfortunately, the the actual timestamp of the file does not correspond with the timestamp in the filename.
can you share with me how I can use the sort in this case ?

If the last modification timestamp matches the file name then just use ls -t.
Otherwise try something like...

ls *.xml | awk -F _ '{print $NF "\t" $0}' | sort | cut -f2-

This works great.
Thank you Ygor!