Function SortArray(ByVal SourceArray, ByVal HasTitle As Boolean, ByVal ColIndex1 As Byte, _
Optional ByVal Order1 As Boolean = True, Optional ByVal ColIndex2 As Byte = 0, _
Optional ByVal Order2 As Boolean = True, Optional ByVal ColIndex3 As Byte = 0, _
Optional ByVal Order3 As Boolean = True)
Dim Darr(), Arr()
Dim i As Long, iP As Long, ir As Long, k As Long, R As Long, LenR As Byte, Tmp
Darr = SourceArray
ReDim Arr(1 To UBound(Darr), 1 To UBound(Darr, 2))
If ColIndex1 >= 1 And ColIndex1 <= UBound(Darr, 2) Then
If ColIndex2 = 0 Then
Arr = SortArray1Col(Darr, ColIndex1, Order1, HasTitle, True)
Else
Arr = SortArray1Col(Darr, ColIndex1, Order1, HasTitle)
If ColIndex2 >= 1 And ColIndex2 <= UBound(Darr, 2) Then
Darr = Arr
Arr = SortArray2Col(Darr, ColIndex1, ColIndex1, ColIndex2, Order2, HasTitle)
If ColIndex3 >= 1 And ColIndex3 <= UBound(Darr, 2) Then
Darr = Arr
Arr = SortArray2Col(Darr, ColIndex1, ColIndex2, ColIndex3, Order3, HasTitle)
End If
End If
End If
SortArray = Arr
End If
End Function