TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: velasquez on March 20, 2017, 09:01:56 PM

Title: Help with vl-sort
Post by: velasquez on March 20, 2017, 09:01:56 PM

In my language there are words like "Tê" "Válvula" "pé"
I'm having problems with working with vl-sort
Code: [Select]
(vl-sort '(("Tubo" "Tê" "Tão" "Válvula" "Registro"))  '(lambda (a b) (< (cadr a) (cadr b))))
;;;Returns -> (("Tubo" "Tê" "Tão" "Válvula" "Registro"))         

;;; In my language, the return must be like ->  '(("Tão" "Tê" "Tubo" "Registro" "Válvula"))
Can someone give me a way?
Title: Re: Help with vl-sort
Post by: ifncdylan on March 20, 2017, 09:31:15 PM
Forgive me but what language is it? :)
Title: Re: Help with vl-sort
Post by: kdub_nz on March 20, 2017, 10:36:11 PM
Forgive me but what language is it? :)

I'd guess Portuguese or Spanish.
Title: Re: Help with vl-sort
Post by: gile on March 21, 2017, 02:09:05 AM
Hi,

I don't know why you have a single list nested in a single list, but what you need is simply sort the 'car' of the parent list:
Code - Auto/Visual Lisp: [Select]
  1. (list (vl-sort (car '(("Tubo" "Tê" "Tão" "Válvula" "Registro"))) '<))

which is the same as
Code - Auto/Visual Lisp: [Select]
  1. (list (vl-sort  '("Tubo" "Tê" "Tão" "Válvula" "Registro") '<))
Title: Re: Help with vl-sort
Post by: VovKa on March 21, 2017, 03:30:46 AM
use acad_strlsort
Title: Re: Help with vl-sort
Post by: Peter2 on March 21, 2017, 04:00:17 AM
;;; In my language, the return must be like ...
Can someone give me a way?
I fear that there is no common solution  :-(
For me, the only unique sorting order is "a-z" and "0-9...". All other can be discussed and defined. Is it
So maybe you have to code it for every special character ....
Title: Re: Help with vl-sort
Post by: velasquez on March 21, 2017, 06:43:11 AM
Hi,

I don't know why you have a single list nested in a single list, but what you need is simply sort the 'car' of the parent list:
Code - Auto/Visual Lisp: [Select]
  1. (list (vl-sort (car '(("Tubo" "Tê" "Tão" "Válvula" "Registro"))) '<))

which is the same as
Code - Auto/Visual Lisp: [Select]
  1. (list (vl-sort  '("Tubo" "Tê" "Tão" "Válvula" "Registro") '<))

This list is part of a larger list.
Title: Re: Help with vl-sort
Post by: velasquez on March 21, 2017, 06:44:12 AM
Forgive me but what language is it? :)

My language is Portuguese.