OrganizeNumbers(list/AS) //Associated List to sort by Associated Values
if(!AS)
world << "ERROR: No list."
return
world << "Organizing numbers..."
var
list/TempCount[] = list()
i = 1
Comparer //Value to be compared to the list with
h //Holder. Holds the index of the Comparer for reference later
while(Count.len > 0)
if(i > AS.len)
TempCount[AS[h]] = AS[AS[h]]
AS.Remove(AS[h])
i = 1
if(AS.len)
Comparer = AS[AS[i]]
h = i
for(i,i<=AS.len,i++)
var/b = AS[AS[i]]
if(Comparer < b)break
var/b
for(b=1,b<=TempCount.len,b++)
AS[TempCount[b]] = TempCount[TempCount[b]]
world << "List reorganized!"
It works great, but I wondered if my peers might have more efficient ideas or concepts?
What happens if you put a mixed list into this?
What about a list of strings?
Atoms?
Some sort of modality to determine how to sort would be awesome, too. For example, ascending/descending numeric, ascending/descending text etc.