Files
S.P.L.U.R.T-Station-13/code/__HELPERS/sorts/MergeSort.dm
Poojawa 03086dfa91 Tg 1 28 sync testing/confirmation (#5178)
* maps, tgui, tools

* defines and helpers

* onclick and controllers

* datums

fucking caught that hulk reversal too.

* game and shuttle modular

* module/admin

* oh god they fucking moved antag shit again

* haaaaate. Haaaaaaaaaate.

* enables moff wings

* more modules things

* tgstation.dme

before I forget something important

* some mob stuff

* s'more mob/living stuff

* some carbon stuff

* ayy lmaos and kitchen meat

* Human stuff

* species things

moff wings have a 'none' version too

* the rest of the module stuff.

* some strings

* misc

* mob icons

* some other icons.

* It compiles FUCK BORERS

FUCK BORERS
2018-01-29 04:42:29 -06:00

19 lines
505 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