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

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 345
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: 6219
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 10 x64 - AutoCAD 2017

Custom Build PC