Sort Array

How can I sort an array in Vb60 ?

Thanks in advance for any help
Who is Participating?
deightonConnect With a Mentor Commented:
Using bubble sort

Private Sub sorta(ar())
    Dim a, b, temp
    Dim bFlag As Boolean
    Dim c As Long
    a = LBound(ar)
    b = UBound(ar)
    bFlag = True
    For c = a To b - 1
        If ar(c) > ar(c + 1) Then
            temp = ar(c)
            ar(c) = ar(c + 1)
            ar(c + 1) = temp
            bFlag = False
        End If
    Loop Until bFlag

End Sub

Example call

Private Sub Command1_Click()
Dim x(4), c As Integer

x(0) = 55
x(1) = 3
x(2) = 1
x(3) = 88
x(4) = -1

Call sorta(x)

For c = 1 To 4
Print x(c)

End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.