ArrSort_3Arr

Sort 3 arrays, ascending or descending based on 1st array.
Needed for specific situation, similar to ArrSort_2Arr but this one is 3 arrays.
Returns 1st array after sorting, 2 Arrays will be passed ByRef, so they will get sorted too.

CodeFunctionName
What is this?

Public

Tested

Original Work

Function ArrSort_3Arr(ar1, ByRef ar2, ByRef ar3, Order_1Asc_2Desc, Optional CaseSensative = 1)
    Ord1 = 1
    If Order_1Asc_2Desc = 2 Then Ord1 = 2
    For I = UBound(ar1) - 1 To 0 Step -1
        For J = 0 To I
            If CaseSensative = 1 Then
                Cond1 = ar1(J) > ar1(J + 1)
                If Ord1 = 2 Then Cond1 = ar1(J) < ar1(J + 1)
            Else
                Arritem1 = UCase(ar1(J))
                Arritem2 = UCase(ar1(J + 1))
                Cond1 = Arritem1 > Arritem2
                If Ord1 = 2 Then Cond1 = Arritem1 < Arritem2
            End If
            If Cond1 Then
                temp1 = ar1(J + 1)
                temp2 = ar2(J + 1)
                temp3 = ar3(J + 1)
                ar1(J + 1) = ar1(J)
                ar1(J) = temp1
                ar2(J + 1) = ar2(J)
                ar2(J) = temp2
                ar3(J + 1) = ar3(J)
                ar3(J) = temp3
            End If
        Next
    Next
    ArrSort_3Arr = ar1
End Function

ar1, ByRef ar2, ByRef ar3, Order_1Asc_2Desc, Optional CaseSensative = 1

Views 161

Downloads 57

CodeID
DB ID