Jump to content

Sorting algorithms/Insertion sort: Difference between revisions

Add REALbasic example
(add Ruby)
(Add REALbasic example)
Line 369:
# insert key at position ``low``
seq[:] = seq[:low] + [key] + seq[low:i] + seq[i + 1:]
</lang>
 
 
=={{header|REALbasic}}==
<lang realbasic>
Sub InsertionSort(theList() as Integer)
for insertionElementIndex as Integer = 1 to UBound(theList)
dim insertionElement as Integer = theList(insertionElementIndex)
dim j as Integer = insertionElementIndex - 1
while (j >= 0) and (insertionElement < theList(j))
theList(j + 1) = theList(j)
j = j - 1
wend
theList(j + 1) = insertionElement
next
End Sub
</lang>
 
1

edit

Cookies help us deliver our services. By using our services, you agree to our use of cookies.