Files
fulpstation/code/__HELPERS/sorts/MergeSort.dm
nemvar b87f65d95e Converts ALL typepaths to lowercase (#51642)
* Case of lower

* More changes

* Ruins the nice 420 diff, brainfart when doing the second batch of conversions

* More changes

* Next batch. I think

* Converts even more paths

* Restarts bots

* Capital Free Zone

* Come on travis, do something

* Renames areas

* Bots, please stop dying

* Updates CONTRIBUTING.md and updates a few paths I missed.

* APC recgarftzfvas
/obj/item/computer_hardware/recharger/apc to /obj/item/computer_hardware/recharger/apc_recharger
2020-06-17 20:47:57 -03:00

20 lines
507 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/sort_instance/SI = GLOB.sortInstance
if(!SI)
SI = new
SI.L = L
SI.cmp = cmp
SI.associative = associative
SI.mergeSort(fromIndex, toIndex)
return L