<razzy>
Regenaxer: can (sort) handle weird '("f" "g" "4") lists?
<razzy>
: (version)
<razzy>
21.7.22
<razzy>
-> (21 7 22)
<beneroth>
razzy, 1) sort is not broken. It's destructive! So the list in the value of A got corrupted, use (setq A (sort ...)) instead of (sort ...)
<beneroth>
2) sort can handle weird lists, as the basic picolisp datatypes (number, symbol, cons-pair) have a strict order, see "Comparison" section in reference: https://software-lab.de/doc/ref.html#cmp
<beneroth>
about 1): your subsequent (sort) calls received different inputs, as A was changed by sort
<razzy>
beneroth: thank you. I was thinking that (sort) is destructive in a way that it changes order. I see my mistake.
<beneroth>
it changes the list given as input
<beneroth>
because it is assumed that the input is anyway throw-away in most use cases
<beneroth>
otherwise use (sort (copy List))
<beneroth>
(copy takes a shallow copy of the list. shallow = only top elements are copied, if they're lists or symbols than the values in those are not duplicated)
<beneroth>
razzy, no worries. been there, it caught me too in the beginning :)