Sorting algorithms/Bubble sort: Difference between revisions
Content added Content deleted
Line 4,981: | Line 4,981: | ||
.Pabcdeefghiiijklmnoooqrstuuvwxyz |
.Pabcdeefghiiijklmnoooqrstuuvwxyz |
||
</pre> |
</pre> |
||
=={{header|Xojo}}== |
|||
<lang xojo>Dim temp, count As Integer |
|||
Dim isDirty As Boolean |
|||
count = Ubound(list) // count the array size |
|||
// loop through until we don't move any numbers... this means we are sorted |
|||
Do |
|||
isDirty = False // we haven't touched anything yet |
|||
For i As Integer = 1 To count - 1 // loop through all the numbers |
|||
If list(i) > list(i + 1) Then // if the right number is smaller then the left.. swap |
|||
temp = list(i + 1) |
|||
list(i + 1) = list(i) |
|||
list(i) = temp |
|||
isDirty = True // we touched the data so mark it as dirty |
|||
End |
|||
Next |
|||
Loop Until isDirty = False // if we made it without touching the data then we are done</lang> |
|||
=={{header|XPL0}}== |
=={{header|XPL0}}== |