RepCad Posted April 29, 2020 Share Posted April 29, 2020 Hi all, I have all file names list of a directory, but it's not sorted, I'm trying to sort them in a new list : (setq lst ("1.dwg" "10.dwg" "11.dwg" "2.dwg" "3.dwg" "4.dwg" "5.dwg" "6.dwg" "7.dwg" "8.dwg" "9.dwg")) (setq li (vl-sort lst '<)) But it returns : ; error: bad function. It should returns : ("1.dwg" "2.dwg" "3.dwg" "4.dwg" "5.dwg" "6.dwg" "7.dwg" "8.dwg" "9.dwg" "10.dwg" "11.dwg") Does somone have any ideas? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 29, 2020 Share Posted April 29, 2020 (setq lst '("1.dwg" "10.dwg" "11.dwg" "2.dwg" "3.dwg" "4.dwg" "5.dwg" "6.dwg" "7.dwg" "8.dwg" "9.dwg" ) ) (vl-sort lst '(lambda (a b) (< (atoi (substr a 1 (- (strlen a) 4))) (atoi (substr b 1 (- (strlen b) 4))) ) ) ) 1 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 29, 2020 Share Posted April 29, 2020 For a generic alphanumerical sort, search for my LM:alphanumsort function. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.