mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
NanoUI fixes from bay and crewmonitor now has a station map so you can easily locate people.
This commit is contained in:
@@ -354,3 +354,49 @@ proc/listclearnulls(list/list)
|
||||
var/list/out = insertion_sort_numeric_list_ascending(L)
|
||||
//world.log << " output: [out.len]"
|
||||
return reverselist(out)
|
||||
|
||||
// List of lists, sorts by element[key] - for things like crew monitoring computer sorting records by name.
|
||||
/proc/sortByKey(var/list/L, var/key)
|
||||
if(L.len < 2)
|
||||
return L
|
||||
var/middle = L.len / 2 + 1
|
||||
return mergeKeyedLists(sortByKey(L.Copy(0, middle), key), sortByKey(L.Copy(middle), key), key)
|
||||
|
||||
/proc/mergeKeyedLists(var/list/L, var/list/R, var/key)
|
||||
var/Li=1
|
||||
var/Ri=1
|
||||
var/list/result = new()
|
||||
while(Li <= L.len && Ri <= R.len)
|
||||
if(sorttext(L[Li][key], R[Ri][key]) < 1)
|
||||
// Works around list += list2 merging lists; it's not pretty but it works
|
||||
result += "temp item"
|
||||
result[result.len] = R[Ri++]
|
||||
else
|
||||
result += "temp item"
|
||||
result[result.len] = L[Li++]
|
||||
|
||||
if(Li <= L.len)
|
||||
return (result + L.Copy(Li, 0))
|
||||
return (result + R.Copy(Ri, 0))
|
||||
|
||||
|
||||
//Mergesort: any value in a list, preserves key=value structure
|
||||
/proc/sortAssoc(var/list/L)
|
||||
if(L.len < 2)
|
||||
return L
|
||||
var/middle = L.len / 2 + 1 // Copy is first,second-1
|
||||
return mergeAssoc(sortAssoc(L.Copy(0,middle)), sortAssoc(L.Copy(middle))) //second parameter null = to end of list
|
||||
|
||||
/proc/mergeAssoc(var/list/L, var/list/R)
|
||||
var/Li=1
|
||||
var/Ri=1
|
||||
var/list/result = new()
|
||||
while(Li <= L.len && Ri <= R.len)
|
||||
if(sorttext(L[Li], R[Ri]) < 1)
|
||||
result += R&R[Ri++]
|
||||
else
|
||||
result += L&L[Li++]
|
||||
|
||||
if(Li <= L.len)
|
||||
return (result + L.Copy(Li, 0))
|
||||
return (result + R.Copy(Ri, 0))
|
||||
Reference in New Issue
Block a user