Files
Paradise/code/__HELPERS/sorts/InsertSort.dm
T
warriorstar-orion 0ffa8303a7 Rename all non-snake_case types. (#27268)
* refactor: Rename all non-snake_case types (not procs or vars (yet)).

* completely dynamic update script

* might help to include the data

* update aa's scuffed python

* oh

* set script PR number

* run updatepaths again

* Add other table updates with JSON columns

* bump SQL version

* just fucking end my life

* move JSON data
2024-11-30 19:08:45 +00:00

20 lines
560 B
Plaintext

//simple insertion sort - generally faster than merge for runs of 7 or smaller
/proc/sortInsert(list/L, cmp = GLOBAL_PROC_REF(cmp_numeric_asc), associative, fromIndex = 1, toIndex = 0)
if(length(L) >= 2)
fromIndex = fromIndex % length(L)
toIndex = toIndex % (length(L) + 1)
if(fromIndex <= 0)
fromIndex += length(L)
if(toIndex <= 0)
toIndex += length(L) + 1
var/datum/sort_instance/SI = GLOB.sortInstance
if(!SI)
SI = new
SI.L = L
SI.cmp = cmp
SI.associative = associative
SI.binarySort(fromIndex, toIndex, fromIndex)
return L