[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String comparison
- From: Matthew Wild <mwild1@...>
- Date: Fri, 18 Dec 2009 13:09:12 +0000
2009/12/18 Andreas Falkenhahn <andreas@airsoftsoftwair.de>:
>
> Hi,
>
> I noticed that the following expression is actually FALSE in lua:
>
> "Big" > "ants"
>
> This seems to happen because of the difference in case because
> the following expression is TRUE:
>
> "Big" > "Ants"
>
> Is there any specific reason why lua does string comparison in
> this way? I.e. giving lower case characters a higher priority than
> all of the upper case characters? I.e. the following is TRUE:
>
Can you name a language which /doesn't/ do it this way?
> "a" > "Z"
>
> It's a little bit confusing... especially when using the sort() function
> of lua's table library.
http://www.lua.org/manual/5.1/manual.html#pdf-table.sort
t = {"Dave", "dave", "mary", "Mary", "Adam", "adam"}
table.sort(t, function (a, b) return a:upper() < b:upper() end);
Matthew