Author Topic: Sort a Dotted Pair of Lists Based on 2nd Value in each List  (Read 946 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 494
Sort a Dotted Pair of Lists Based on 2nd Value in each List
« on: March 16, 2017, 01:36:17 PM »
How to Sort a Dotted Pair of Lists Based on 2nd Value in each List.
For example :

(
(<Entity name: 7fffef51d00> . "W 2")
(<Entity name: 7fffef51cf0> . "W 1")
(<Entity name: 7fffef51ce0> . "W 5")
(<Entity name: 7fffef51cd0> . "W 3")
)

be sorted to :

(
(<Entity name: 7fffef51cf0> . "W 1")
(<Entity name: 7fffef51d00> . "W 2")
(<Entity name: 7fffef51cd0> . "W 3")
(<Entity name: 7fffef51ce0> . "W 5")
)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Sort a Dotted Pair of Lists Based on 2nd Value in each List
« Reply #1 on: March 16, 2017, 01:41:03 PM »
Code - Auto/Visual Lisp: [Select]
  1. (vl-sort yourlist (function (lambda (a b) (< (cdr a) (cdr b)))))
Similar question HERE.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC