mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Simplify code of mainmenu world sort
This commit is contained in:
parent
7fbc8152bf
commit
779165144e
1 changed files with 6 additions and 14 deletions
|
@ -240,17 +240,9 @@ end
|
||||||
function sort_worlds_alphabetic(this)
|
function sort_worlds_alphabetic(this)
|
||||||
|
|
||||||
table.sort(this.m_processed_list, function(a, b)
|
table.sort(this.m_processed_list, function(a, b)
|
||||||
local n1 = a.name
|
if a.name:lower() == b.name:lower() then
|
||||||
local n2 = b.name
|
return a.name < 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
|
||||||
end
|
return a.name:lower() < b.name:lower()
|
||||||
return (#n1 <= #n2)
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue