[Tutor] Sorting a directory

Jonas Melian jonasmg at softhome.net
Tue May 24 16:02:01 CEST 2005


Hi all,

I have to working with the files lines in this directory:

:::
dir_locales = "/usr/share/i18n/locales/"

for line in fileinput.input(glob.glob(os.path.join\
            (dir_locales, "*_[A-Z][A-Z]"))):
...

:::

The problem is that the directory otuput is:
aa_DJ
aa_ER
aa_ET
af_ZA
...

and i would sort this files by the 2 last letters, so:
aa_DJ
so_DJ
aa_ER
byn_ER
gez_ER
ti_ER
tig_ER
...

I have not foun a lot of info about sort

Thanks!


More information about the Tutor mailing list