Simple 1d array bubble sort module
Simply sorts a 1 dimensional array using a bubble sort algorythm.
AI
Ringkasan AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Kode Sumber
'
'Use:
'
'Sort Array
'
'to sort (A-Z / 1-10, Accending)
'Pretty easy to update it to sort 2 or 3 dimensional arrays
'Or to sort decending
'
'Comments or any info email: col@woor.co.uk
'
Public Sub sort(tmparray)
Dim SortedArray As Boolean
Dim start, Finish As Integer
SortedArray = True
start = LBound(tmparray)
Finish = UBound(tmparray)
Do
SortedArray = True
For loopcount = start To Finish - 1
If tmparray(loopcount) > tmparray(loopcount + 1) Then
SortedArray = False
Call swap(tmparray, loopcount, loopcount + 1)
End If
Next loopcount
Loop Until SortedArray = True
End Sub
Sub swap(swparray, fpos, spos)
Dim temp As Variant
temp = swparray(fpos)
swparray(fpos) = swparray(spos)
swparray(spos) = temp
End Sub
Upload
Komentar Asli (3)
Dipulihkan dari Wayback Machine