ArrSort_4Arr

Sort 4 1-dimension arrays
Actually sort 1st array (arrShort) based on values ascending or descending, then change items in arrSub, arrSub2 and arrSub3 to match order in arrShort
Sort can be in Ascending or Descending order.
Similar to ArrSort_2Arr and ArrSort_3Arr but fir 4 arrays.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function ArrSort_4Arr(arrShort, ByRef arrSub, ByRef arrSub2, ByRef arrSub3, Order_1Asc_2Desc, Optional CaseSensative = 1)
    Ord1 = 1
    If Order_1Asc_2Desc = 2 Then Ord1 = 2
    For I = UBound(arrShort) - 1 To 0 Step -1
        For J = 0 To I
            If CaseSensative = 1 Then
                Cond1 = arrShort(J) > arrShort(J + 1)
                If Ord1 = 2 Then Cond1 = arrShort(J) < arrShort(J + 1)
            Else
                Arritem1 = UCase(arrShort(J))
                Arritem2 = UCase(arrShort(J + 1))
                Cond1 = Arritem1 > Arritem2
                If Ord1 = 2 Then Cond1 = Arritem1 < Arritem2
            End If
            If Cond1 Then
                temp = arrShort(J + 1)
                temp1 = arrSub(J + 1)
                temp2 = arrSub2(J + 1)
                temp3 = ArrSub3(J + 1)
                ArrSub3(J + 1) = ArrSub3(J)
                ArrSub3(J) = temp3
                arrSub2(J + 1) = arrSub2(J)
                arrSub2(J) = temp2
                arrSub(J + 1) = arrSub(J)
                arrSub(J) = temp1
                arrShort(J + 1) = arrShort(J)
                arrShort(J) = temp
            End If
        Next
    Next
    ArrSort_4Arr = arrShort
End Function

arrShort, ByRef arrSub, ByRef arrSub2, ByRef arrSub3, Order_1Asc_2Desc, Optional CaseSensative = 1

Views 154

Downloads 100

CodeID
DB ID