Hi list, I have a problem.

Whenever I sort a list stored in a symbol, some elements are erased
from the original list. Look:

: (setq A (3 2 5 4 1 1 1 1 0 1 2 4 5 ))
-> (3 2 5 4 1 1 1 1 0 1 2 4 5)
: (sort A)
-> (0 1 1 1 1 1 2 2 3 4 4 5 5)
: A
-> (3 4 4 5 5)

The pattern that I've noticed is that any element that is smaller than the
CAR of the original list is lost in the sorting.

Its not limited to numbers either:

: (setq A '(a 3 2 5 4 1 1 1 1 0 1 2 4 5 ))
-> (a 3 2 5 4 1 1 1 1 0 1 2 4 5)
: (sort A)
-> (0 1 1 1 1 1 2 2 3 4 4 5 5 a)
: A
-> (a)

If its used with 'by, there is no loss:

: (setq A '(a 3 2 5 4 1 1 1 1 0 1 2 4 5 ))
-> (a 3 2 5 4 1 1 1 1 0 1 2 4 5)
: (by > sort A)
-> (0 1 1 1 1 1 2 2 3 4 4 5 5 a)
: A
-> (a 3 2 5 4 1 1 1 1 0 1 2 4 5)

But that might be because with 'by, the operation is not destructive.

Is this normal operation of picolisp? I assumed its not, because I didn't
catch any reference to it in the documentation.

I'd quite appreciate any help, and if you have any questions let me know.

P.S.
I'm using version 16.6.0, on Ubuntu 16.04

Reply via email to