Thread Tools Display Modes
Prev Previous Post   Next Post Next
08/21/15, 09:34 AM   #1
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
[outdated] strcmp, or a proper operator < on strings

Operator < on strings in ESO-Lua ignores everything except letters and digits. It's useless for sorting strings containing spaces and/or punctuation, as it doesn't define a total order.

Examples:
Lua Code:
  1. "a" < "A" == true
  2. "b" < "A" == false
  3. "A" < "a" == false
  4. "B" < "c" == true
  5. -- interesting, the order is: "a", "A", "b", "B", "c", ...
  6. -- that's nice, actually
  7.  
  8. "aa" < "A" == false
  9. "aa" < "Aa" == true
  10. -- more surprises, the order is: "a", "aa", "aA", "Aa", "AA", ...
  11. -- but still fine
  12.  
  13. "a head" < "ahead" == false
  14. "ahead" < "a head" == false
  15. -- they're not equal, yet neither is less than the other
  16. -- this is bad, table.sort will not give consistent order
  17.  
  18. "#" < "~" == false
  19. "~" < "#" == false
  20. -- it doesn't compare the characters at all
 
 

ESOUI » Developer Discussions » Wish List » [outdated] strcmp, or a proper operator < on strings


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off