Author Topic: Help with vl-sort  (Read 2504 times)

0 Members and 1 Guest are viewing this topic.

velasquez

  • Newt
  • Posts: 195
Help with vl-sort
« 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?

ifncdylan

  • Guest
Re: Help with vl-sort
« Reply #1 on: March 20, 2017, 09:31:15 PM »
Forgive me but what language is it? :)

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2120
  • class keyThumper<T>:ILazy<T>
Re: Help with vl-sort
« Reply #2 on: March 20, 2017, 10:36:11 PM »
Forgive me but what language is it? :)

I'd guess Portuguese or Spanish.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Help with vl-sort
« Reply #3 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") '<))
Speaking English as a French Frog

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Help with vl-sort
« Reply #4 on: March 21, 2017, 03:30:46 AM »
use acad_strlsort

Peter2

  • Swamp Rat
  • Posts: 650
Re: Help with vl-sort
« Reply #5 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
  • "A a B b" or "a A b B"
  • "a ä" or "ä a" or "a-z ä" (German Umlaute)
  • "â a á à or á a à â or ....(other diacritics)
  • what's about the letters which are beyond a-z? (IIRC "ck" is an own letter in Czech ....)
So maybe you have to code it for every special character ....
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

velasquez

  • Newt
  • Posts: 195
Re: Help with vl-sort
« Reply #6 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.

velasquez

  • Newt
  • Posts: 195
Re: Help with vl-sort
« Reply #7 on: March 21, 2017, 06:44:12 AM »
Forgive me but what language is it? :)

My language is Portuguese.