Hi, The sort is destructive of the input. https://software-lab.de/doc/refS.html#sort There are other functions that behave like this that you need to be aware of when writing code. You have to assign the result of the sort to another variable. Back to itself is fine.
: (setq L '((3) (2) (1))) -> ((3) (2) (1)) : (show L) -> ((3) (2) (1)) : (setq L (sort L)) -> ((1) (2) (3)) : (show L) -> ((1) (2) (3)) : (length L) -> 3 Regards, /Lindsay On Sat, May 4, 2019 at 7:32 AM C K Kashyap <ckkash...@gmail.com> wrote: > Hi all, > > I noticed an odd behavior of sort - > > (setq L '((2) (1) )) > > > (println (length L)) # 2 as expected > > (sort L) > > (println (length L)) # why 1? > > (println L) # ((2)) > > (bye) > > I would expect sort not to change the length. Am I missing something here > or is sort broken? > Regards, > Kashyap >