x11start
Guest
to order lists there are 2 commands:
- the most "old" (which only orders string lists) is called acad_strlsort
- while the most recent (because introduced with all other vl-xxx commands from version 2000 or so...), it is called vl-sort.
the latter has the advantage of allowing the reordering also of the whole and real numbers and selecting the order from the minor to the major or vice versa; what with acad-strlsort, you can do it only by doing (reverse (acad-strlsort nomelista).
it seems therefore that vl-sort is definitely better than the predecessor ... however, having made a lisp in autocad and then having launched it on gstarcad.... I had a (just pleasant!) surprise:
e.g. (setq list '("3" "0" "2" "1" "0" "2"))
on autocad doing:
(acad-strlsort list)
I get:
'("0" "0" "1" "2" "2" "2" "3")
the same result I get by doing the command:
(vl-sort list <)
.... but if I use vl-sort in gstarcad the result becomes:
"("0" "1" "2" "3")
practically the command "deletes the doubles"... and the thing can create serious operating problems at the lisp!
Unfortunately, as I mentioned before, the acad-strlsort command, does not allow to reorder the numbers but only the strings, so today I will try to change my "module" lisp for the ordinations, to make sure that the n. Reals are transformed into strings, before the order... paying attention to putting them "0" in front; this because otherwise the list...
("10" "1" "8") would become ("1" "10" "8")
instead with opportuni "0" in front.. .
("10" "01" "08") becomes ("01" "08" "10")... that retransformed in whole is the right sequence.. .
last note:
There is also a command called vl-sort-i, which serves to order a list "taking" the order in which another list should be ordered.. .
Well: this command works very well on gstarcad.... in the sense that in this case you do not "eat" indexes, in case the reference list to be processed, have double values!
- the most "old" (which only orders string lists) is called acad_strlsort
- while the most recent (because introduced with all other vl-xxx commands from version 2000 or so...), it is called vl-sort.
the latter has the advantage of allowing the reordering also of the whole and real numbers and selecting the order from the minor to the major or vice versa; what with acad-strlsort, you can do it only by doing (reverse (acad-strlsort nomelista).
it seems therefore that vl-sort is definitely better than the predecessor ... however, having made a lisp in autocad and then having launched it on gstarcad.... I had a (just pleasant!) surprise:
e.g. (setq list '("3" "0" "2" "1" "0" "2"))
on autocad doing:
(acad-strlsort list)
I get:
'("0" "0" "1" "2" "2" "2" "3")
the same result I get by doing the command:
(vl-sort list <)
.... but if I use vl-sort in gstarcad the result becomes:
"("0" "1" "2" "3")
practically the command "deletes the doubles"... and the thing can create serious operating problems at the lisp!
Unfortunately, as I mentioned before, the acad-strlsort command, does not allow to reorder the numbers but only the strings, so today I will try to change my "module" lisp for the ordinations, to make sure that the n. Reals are transformed into strings, before the order... paying attention to putting them "0" in front; this because otherwise the list...
("10" "1" "8") would become ("1" "10" "8")
instead with opportuni "0" in front.. .
("10" "01" "08") becomes ("01" "08" "10")... that retransformed in whole is the right sequence.. .
last note:
There is also a command called vl-sort-i, which serves to order a list "taking" the order in which another list should be ordered.. .
Well: this command works very well on gstarcad.... in the sense that in this case you do not "eat" indexes, in case the reference list to be processed, have double values!