lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2014-06-05 0:10 GMT+02:00 Jay Carlson <nop@nop.com>:

> sortedStrings = stringArray:sorted(function (a,b)
>     return a:uppercaseString() < b:uppercaseString()
>     end)

Personally, though that sort of code is legal Lua, I find
it obfuscated.

function ALPHABETICALLY(a,b)
    return a:uppercaseString() < b:uppercaseString()
end

-- ... 1000 lines of code later

sortedStrings = stringArray:sorted(ALPHABETICALLY)

When you read that line, no need to wonder what it means.