var/list/L = list("Cake","Chocolate","Pie")
I'm turning everything in the list to a number. Then I'm bubble sorting that number list(for those who don't know what bubble sorting is, it organizes a list of numbers in ascending or descending order).
So lets say the new number list looks like this:
var/list/Lnum = list(1,2,3)
How can I now turn Lnum back into L but still sorted?
I know that sounds confusing so I'll explain it a bit:
Lets assume:
Cake = 3
Pie = 2
Chocolate = 1
After bubble sorting it, I get the list "1,2,3".
How can I now turn the new list into "Chocolate,Pie,Cake" as opposed to the original "Cake,Chocolate,Pie"?
Well, for one, it makes a whole lot more sense just to sort the list in the first place instead of getting a list of numbers, sorting that, and then converting the number list back into its original medium.
How exactly to accomplish this, of course, depends alot on what parameter you're sorting by.
If you're sorting a list of text, for example, you'll probably want an associative list in the format, element_to_be_sorted == parameter_to_sort_by. In that case, you could use a proc like this:
If you want to test it, try the following verb out:
Please note that associative_bubble_sort() MUST take a completely associative list as an argument.
If you want to sort a non-associative list, then use this proc, which I programmed for you in another post: