sort files

i have a folder contails 3 types of files ,
ls -l
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml002.agl
-rw-r--r-- 1 oratest dba 6 Jul 1 15:43 aml003.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom002.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:44 bom003.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:35 item001.agl
-rw-r--r-- 1 oratest dba 9 Jul 1 15:35 item002.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:43 item003.agl

aml , bom , item

i want a script which sort the files by the number after the name,
i want to get the following result after the sort command:

-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom001.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:35 item001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml002.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom002.agl
-rw-r--r-- 1 oratest dba 9 Jul 1 15:35 item002.agl
-rw-r--r-- 1 oratest dba 6 Jul 1 15:43 aml003.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:44 bom003.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:43 item003.agl

all 001 files will be first , then 002 files and so

the number could be with 4 digits and 5 ...

thanks

Use CODE-tags when you post code, data or logs. Also it is nice that you want a script - what have you tried so far?

Funny complication, but it somehow works

for j in $(for i in *agl ; do echo $i | sed -e 's/\([a-z]\+\)\([0-9]\+\)/\2\1/g'  ; done | sort | sed -e 's/\([0-9]\+\)\([a-z]\+\)/\2\1/g') ; do ls -l $j ; done

thanks a lot
you are a very god man

Best Regards

ls -l | nawk '{tmp=$9; gsub(/[^[0-9]]*/,"",tmp); print tmp" "$0;}' | sort -n | awk '{$1="";print}'

perl:

open FH,"ls -l *.agl|";
my @arr=<FH>;
print map {$_->[0]} 
      sort {$a->[1] <=> $b->[1]} 
      map {/(?:[^ ]+\s*){8}[^[0-9]]*([0-9]+)\..*$/;[$_,$1]} 
      @arr;