by Brent (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 26th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Bubble sort an array in less than 20 lines of code
Dim Fnames() As Long
Dim I As Integer
Dim swop As Boolean
Dim a, B As Long
Dim Arrterms As Integer
swop = False
Do While True
For I = 0 To Arrterms - 1
If Fnames(I) > Fnames(I + 1) Then
a = Fnames(I)
B = Fnames(I + 1)
Fnames(I) = B
Fnames(I + 1) = a
swop = True
End If
Next I
If I = Arrterms Then I = 0
If swop = False Then Exit Do
swop = False
Loop