Author Topic: Sort List retrieved from vl-file-systime  (Read 3674 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Sort List retrieved from vl-file-systime
« Reply #15 on: July 17, 2009, 01:01:34 PM »
I realise that, however, if the foo predicate function does return T, what does vl-sort do in turn? Perhaps I am missing something on this one  :|

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Sort List retrieved from vl-file-systime
« Reply #16 on: July 17, 2009, 01:07:29 PM »
I realise that, however, if the foo predicate function does return T, what does vl-sort do in turn?

Ahhh, gotchu. Once might conclude that it swaps the items but I doubt that is the case as it would imply a bubble sort, the worst performing sort of all sort algorithms. My guess is that vl-sort uses the predicate's results to index the items then performs a merge or quick sort, but heh, it's just a guess. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Sort List retrieved from vl-file-systime
« Reply #17 on: July 17, 2009, 01:20:15 PM »
I know what you mean about the bubble sort, I had to manually write one out for one of my maths modules... tedious indeed. But thanks for the insight. I just wondered to its operation as I wouldn't know how to structure the predicate function depending on how the vl-sort dealt with the returns from the predicate function.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Sort List retrieved from vl-file-systime
« Reply #18 on: July 17, 2009, 01:32:37 PM »
I wouldn't know how to structure the predicate function depending on how the vl-sort dealt with the returns from the predicate function.

You're clear on it now? All you need do is ensure it (the predicate function) returns non nil in the event that item 1 is less than item 2 (assuming normal ascending sort). What establishes "less than" vl-sort cares not; kinda the beauty of it. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Sort List retrieved from vl-file-systime
« Reply #19 on: July 17, 2009, 01:49:26 PM »
Gotcha Thanks - non-nil for the sorting order that you want to achieve.