help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there a function to sort file names by file version number, like "ls


From: Florian v. Savigny
Subject: Is there a function to sort file names by file version number, like "ls -v"?
Date: Thu, 23 May 2013 04:21:46 -0400

Hi there,

if you backup files using "cp --backup numbered", cp creates version
numbers like this:

xorg.conf.~1~
xorg.conf.~2~
...
xorg.conf.~9~
xorg.conf.~10~
xorg.conf.~11~
...
xorg.conf.~20~

etc.

As these names are not zero-padded, the normal, alphabetical sorting
will sort them like this:

xorg.conf.~10~
xorg.conf.~11~
...
xorg.conf.~1~
xorg.conf.~20~
xorg.conf.~21~
xorg.conf.~2~
...
xorg.conf.~9~

which is definitely not what is normally useful. For this reason, ls
seems to have the -v switch, which sorts them as shown in the first
listing.

I am wondering if there is somehow a comparison function (of the same
category as string-lessp) in Elisp which compares file name strings by
these version numbers, so I could sort the result of
directory-file-names in the same way as "ls -v".

Is there? (There must be! ;-))

Thank you very much in advance!

Best regards,

Florian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]