Author Topic: vl-sort working in ACAD but not in BricCAD  (Read 4346 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3309
  • Marko Ribar, architect
Re: vl-sort working in ACAD but not in BricCAD
« Reply #15 on: October 02, 2023, 10:49:11 PM »
I just don't know what's wrong with this simple method :

Whether ACAD_STRLSORT is appropriate depends on the expected result and on how well ordered the data is.     

 (acad_strlsort  '("P3" "P1" "P2" "P123" "P11"))
; ("P1" "P11" "P123" "P2" "P3")

If what you want is ASCII order it is fine.  For most of my purposes I would want the result to be P1, P2, P3, P11, P123

You are right, just checked...
: TEST1

(("P1" "B1") ("P2" "B1") ("P3" "B2") ("P11" "B4") ("P123" "B4"))
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8800
  • AKA Daniel
Re: vl-sort working in ACAD but not in BricCAD
« Reply #16 on: October 02, 2023, 11:56:59 PM »
Lexicographic vs Numerical
5 is numerically less than 10, but "10" is lexicographically less than "5"
With my table sort routine, if the string starts with a number, its sorted numerically, else lexicographically