Sorting algorithms/Bubble sort: Difference between revisions

m
→‎{{header|AutoHotkey}}: Minor indentation and casing edit
m (→‎{{header|Ruby}}: formatting)
m (→‎{{header|AutoHotkey}}: Minor indentation and casing edit)
Line 141:
abc
)
msgboxMsgBox % bubblesort(var)
 
bubblesort(var) ; each line of var is an element of the array
{
stringsplit StringSplit, array, var, `n
hasChanged = 1
size := array0
while While hasChanged
{
hasChanged = 0
loop, % (size - 1)
{
ihasChanged := array%A_Index%0
A_IndexjLoop, :=% A_Index(size +- 1)
j := array%A_Indexj%
if (j < i)
{
temp i := array%A_Index%
array%A_Index% aj := array%A_Indexj%A_Index + 1
array%A_Indexj% j := temparray%aj%
hasChanged = 1If (j < i)
} {
j temp := array%A_IndexjA_Index%
sorted .= array%A_Index% .:= "`n"array%aj%
array%aj% := temp
hasChanged = 01
if (j <} i)
}
}
loopLoop, % (size - 1)
}
sorted .= array%A_Index% . "`n"
loop, % size
return Return sorted
{
sorted .= array%A_Index% . "`n"
}
return sorted
}
</lang>