Hi Alex,

the 'sort' function has the less-than relation built-in.  Is there an
"easy" way of sorting a list using a user-defined less-than relation?

I wanted to reuse the existing 'sort' function and came up with:

(de order (Lt Lst)
   (let Q NIL
      (for X Lst
         (let S 0
            (for Y Lst
               (when (apply Lt NIL X Y)
                  (inc 'S) ) ) )
         (push 'Q (cons S X)) )
      (flip (mapcar cdr (by car sort Q))) ) )

That is quite simple but not efficient.

Could the existing 'sort' function be extended for the scenario with a
user-defined less-than relation?

Thank you,

UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to