created by AbyssDragon
proc/QuickSort(list/L, low = 1, high = -1)
if(high == -1) high = L.len
if(low >= high) return
var/pivot = QSPartition(L, low, high)
QuickSort(L, low, pivot-1)
QuickSort(L, pivot+1, high)
proc/QSPartition(list/L, low, high)
var/x = L[high]
var/i = low -1
for(var/j in low to high -1)
if(Compare(L[j], x) == 1)
i++
Swap(L, i, j)
Swap(L, i+1, high)
return i + 1
Problem description:
Hi i'm dumb programer. And i need to know how to "sort" O.o list?
But i found 2 sort proc by AbyssDragon.
I have list
var/list/L=list(5,2,1,4,3)
and when i use 1st proc, i have sorted list from lower to higher
var/list/L=list(1,2,3,4,5)
but i need sort from higher to lower.
var/list/L=list(5,4,3,2,1)
return item2<item1?-1:(item1==item2?0:1)
I'd imagine you could switch the less than to a greater than and probably get the whole thing sorting the list the other way around.