Hi Guys,
I am writing a LISP to deal with multiple drawings, and it requires me to find the most recent drawing. Hence I am using vl-file-systime to get the last modified time of each drawing in a directory.
I have compiled a list of drawing names and their respective modification times, and now need to sort the list.
I have used a form of "remove_nth" to remove the day-of-the-week number from the list, as this is unnecessary for this sort.
The list looks something like this:
'(("Drawing1" (1998 4 8 10 6 52)) ("Drawing2" (1999 5 4 3 4 12))... etc)
I have created this code to sort it, but I wondered if anyone had anything better - call it a challenge if you will..
(defun dSort (lst / lst)
(while
(progn
(cond ((not
(vl-remove-if 'null
(mapcar 'cadr lst)))
(setq lst nil))
((apply '=
(vl-sort
(mapcar 'caadr lst)
(function
(lambda (a b) (< a b)))))
(setq lst (mapcar
(function
(lambda (x)
(list (car x) (cdadr x)))) lst)))
(t (setq lst (caar lst)) nil))))
lst)
The above will (or rather "should") return the name of the most recent drawing.
Lee