<-- Previous || Up || Next -->

Sort Variant Matrix Rows 2nd Sample Sub
Array Sorts Class

Private Sub SortVariantMatrixRows2ndSample()

    'See also:
    '  SortVariantMatrixRowsSample Subroutine
    '  SortVariantMatrixRows Function

    Const NumRows = 4096
    Const MinCols = 2
    Const MaxCols = 10

    '' Create a variant matrix containing some random numbers.

    Dim intCols As Integer
    For intCols = MinCols To MaxCols Step 2
        Debug.Print "Columns = " & intCols

        Dim avarMatrix() As Variant
        ReDim avarMatrix(0 To intCols, 0 To NumRows)
    
        Dim avarKeys() As Variant
        ReDim avarKeys(0 To 2)
    
        Dim lngRow As Long
        For lngRow = LBound(avarMatrix, 2) To UBound(avarMatrix, 2)
            Dim intCol As Integer
            For intCol = LBound(avarMatrix, 1) To UBound(avarMatrix, 1)
                avarMatrix(intCol, lngRow) = RandomDoubleWithinRange(0, 100)
            Next intCol
        Next lngRow
    
        avarKeys(1) = 1
        avarKeys(2) = 2
        Debug.Print "SortVariantMatrix (Rnd) to (1,2):"
        DebugTimerOn
        SortVariantMatrixRows avarMatrix, Null, avarKeys, False
        Debug.Print DebugTimerOff
    
        avarKeys(1) = 1
        avarKeys(2) = 2
        Debug.Print "SortVariantMatrix (1,2) to (1,2):"
        DebugTimerOn
        SortVariantMatrixRows avarMatrix, Null, avarKeys, False
        Debug.Print DebugTimerOff
    
        avarKeys(1) = 2
        avarKeys(2) = 1
        Debug.Print "SortVariantMatrix (1,2) to (2,1):"
        DebugTimerOn
        SortVariantMatrixRows avarMatrix, Null, avarKeys, False
        Debug.Print DebugTimerOff
    
        avarKeys(1) = 2
        avarKeys(2) = 1
        Debug.Print "SortVariantMatrix (2,1) to (2,1):"
        DebugTimerOn
        SortVariantMatrixRows avarMatrix, Null, avarKeys, False
        Debug.Print DebugTimerOff
    
        avarKeys(1) = 1
        avarKeys(2) = 2
        Debug.Print "SortVariantMatrix (2,1) to (1,2):"
        DebugTimerOn
        SortVariantMatrixRows avarMatrix, Null, avarKeys, False
        Debug.Print DebugTimerOff

    Next intCols
End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.