I’ve searched the forum for a sort function that sorts a list of files or part numbers the way windows sorts filenames. I didn’t have any luck, but I did find some very useful utilities, such as “getdir” by ronjonp.
The vl-directory-files functions sorts the files the same way that acad_strlsort would sort these filenames in a list. Example:
(setq FileList@ (vl-directory-files Foldername$ "*.dwg" 1))
(setq SortList@ (acad_strlsort FileList@))
Both return the following list:
(list “PN375-A10.dwg”
“PN375-A9.dwg”
“PN375-D1.dwg”
“PN375-D10.dwg”
“PN375-D14.dwg”
“PN375-D2.dwg”
“PN375-D22.dwg”
“PN375-D7r3.dwg”
“PN375-DB.dwg”
“PN375-DB10a.dwg”
“PN375-DB9.dwg”)
The order that I’m wanting is:
(list “PN375-A9.dwg”
“PN375-A10.dwg”
“PN375-D1.dwg”
“PN375-D2.dwg”
“PN375-D7r3.dwg”
“PN375-D10.dwg”
“PN375-D14.dwg”
“PN375-D22.dwg”
“PN375-DB9.dwg”
“PN375-DB10a.dwg”
“PN375-DB.dwg”)
I can see the unique groups of PN375-A, PN375-D, PN375-DB. The sort is then based on the numbers that follow the unique groups.
If I missed this topic in my search, please point me to the right thread.
Thanks,
Terry