I don't know if it's the most efficient way, but I'd do something like this:
Variables:
A (integer) = 0
B (integer) = 0
TemporaryStorage (real) = 0.0
ArrayLength = 10
General - For each integer A from 0 to (ArrayLength - 2) with increment 1, do (Actions)
Actions
General - For each integer B from (A + 1) to (ArrayLength - 1) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Array[A] > Array[B]
Then
Variable - Set TemporaryStorage = Array[B]
Variable - Set Array[B] = Array[A]
Variable - Set Array[A] = TemporaryStorage
Else
That will just compare each number to all the numbers after it, and if it finds one that's smaller then it'll trade places. I don't know if there's a way to get the length of an array automatically, so you'll have to adjust ArrayLength yourself to however long the array is.
Don't listen to him about bubble sort. Bubble sort blows.
You can try bozo sort if you'd like. Bozo sort randomly switches around every element of the array, then checks if they're sorted. If they're not sorted, it switches them randomly again. Repeat until sorted.
Blizzard implemented some search algorithms as templates. Have a look at Triggers -> Libraries (to show libraries press ctrl+shift+L) -> Built-in -> Templates -> Algorithms.
They have Bubblesort, Selectionsort, Insertionsort and Quicksort (which is a kind of standard and would be preferable for most applications, I guess)
How to sort an array of real numbers, in ascending order?
I don't know if it's the most efficient way, but I'd do something like this:
Variables:
A (integer) = 0
B (integer) = 0
TemporaryStorage (real) = 0.0
ArrayLength = 10
General - For each integer A from 0 to (ArrayLength - 2) with increment 1, do (Actions)
Actions
General - For each integer B from (A + 1) to (ArrayLength - 1) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Array[A] > Array[B]
Then
Variable - Set TemporaryStorage = Array[B]
Variable - Set Array[B] = Array[A]
Variable - Set Array[A] = TemporaryStorage
Else
That will just compare each number to all the numbers after it, and if it finds one that's smaller then it'll trade places. I don't know if there's a way to get the length of an array automatically, so you'll have to adjust ArrayLength yourself to however long the array is.
mmmm bubble sort
Ok, thanks for the help
Google "Merge sort" or "Quick Sort".
Don't listen to him about bubble sort. Bubble sort blows.
You can try bozo sort if you'd like. Bozo sort randomly switches around every element of the array, then checks if they're sorted. If they're not sorted, it switches them randomly again. Repeat until sorted.
Blizzard implemented some search algorithms as templates. Have a look at Triggers -> Libraries (to show libraries press ctrl+shift+L) -> Built-in -> Templates -> Algorithms.
They have Bubblesort, Selectionsort, Insertionsort and Quicksort (which is a kind of standard and would be preferable for most applications, I guess)
I've just been reading about those sorting algorithms on Wikipedia. Turns out I invented off the top of my head a Selection Sort. Who'da thunk?
@Vexal: Go
LOL