Sorting nil and true

Q&A's, tips, howto's
Locked
cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Sorting nil and true

Post by cameyo »

How to sort a list containing nil and true symbols?

Code: Select all

(setq a '(nil true b a))
(sort a)
;-> (nil true a b)
Thanks

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: Sorting nil and true

Post by cameyo »

I have found this method:

Code: Select all

(setq lst '(true nil true b a))
(map sym (sort (map string lst)))
;-> (a b nil true true)
cameyo

Locked