mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-19 23:01:35 +00:00
* 515 compat * double spaces * Callback documentation, aa review * spacing * NAMEOF_STATIC * big beta
21 lines
469 B
Plaintext
21 lines
469 B
Plaintext
//TimSort interface
|
|
/proc/sortTim(list/L, cmp = GLOBAL_PROC_REF(cmp_numeric_asc), associative, fromIndex = 1, toIndex = 0)
|
|
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.timSort(fromIndex, toIndex)
|
|
return L
|