diff options
author | Novatux <nathanael.courant@laposte.net> | 2013-08-05 18:49:19 +0200 |
---|---|---|
committer | PilzAdam <pilzadam@minetest.net> | 2013-08-06 18:33:23 +0200 |
commit | 779165144eb8c898ab9dd0b8a39526ce6037e325 (patch) | |
tree | 77774a9fe818982125d12c80f988777d1192a212 /builtin | |
parent | 7fbc8152bfdb7f020a02f3c90ba6198393f0062c (diff) | |
download | minetest-779165144eb8c898ab9dd0b8a39526ce6037e325.tar.gz minetest-779165144eb8c898ab9dd0b8a39526ce6037e325.tar.bz2 minetest-779165144eb8c898ab9dd0b8a39526ce6037e325.zip |
Simplify code of mainmenu world sort
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/filterlist.lua | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/builtin/filterlist.lua b/builtin/filterlist.lua index c9135d207..906c339df 100644 --- a/builtin/filterlist.lua +++ b/builtin/filterlist.lua @@ -239,18 +239,10 @@ end -------------------------------------------------------------------------------- function sort_worlds_alphabetic(this) - table.sort(this.m_processed_list, function(a, b) - local n1 = a.name - local n2 = b.name - local count = math.min(#n1, #n2) - - for i=1,count do - if n1:sub(i, i):lower() < n2:sub(i, i):lower() then - return true - elseif n1:sub(i, i):lower() > n2:sub(i, i):lower() then - return false - end - end - return (#n1 <= #n2) - end) + table.sort(this.m_processed_list, function(a, b) + if a.name:lower() == b.name:lower() then + return a.name < b.name + end + return a.name:lower() < b.name:lower() + end) end |