mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-06 11:50:55 +01:00
04ba5c1cc9
* Adds the check components * Adds in trailing newlines * Converts all CRLF to LF * Post merge EOF * Post merge line endings * Final commit
20 lines
512 B
Plaintext
20 lines
512 B
Plaintext
//merge-sort - gernerally faster than insert sort, for runs of 7 or larger
|
|
/proc/sortMerge(list/L, cmp = /proc/cmp_numeric_asc, associative, fromIndex = 1, toIndex)
|
|
if(L && L.len >= 2)
|
|
fromIndex = fromIndex % L.len
|
|
toIndex = toIndex % (L.len + 1)
|
|
if(fromIndex <= 0)
|
|
fromIndex += L.len
|
|
if(toIndex <= 0)
|
|
toIndex += L.len + 1
|
|
|
|
var/datum/sortInstance/SI = GLOB.sortInstance
|
|
if(!SI)
|
|
SI = new
|
|
SI.L = L
|
|
SI.cmp = cmp
|
|
SI.associative = associative
|
|
|
|
SI.mergeSort(fromIndex, toIndex)
|
|
return L
|