Private Sub SortVariantVectorSample() ' Generate some sample data. Const NumElems = 256 Dim avarOrig() As Variant ReDim avarOrig(0 To NumElems) Dim lngCurElem As Long For lngCurElem = 1 To UBound(avarOrig) avarOrig(lngCurElem) = RandomString(Null, Null, Null) avarOrig(lngCurElem) = "Sample" Next lngCurElem ' Perform some tests. Dim avarQuick() As Variant CopyVariantVectorDirect avarQuick, avarOrig Debug.Print "SortVariantVector:" DebugTimerOn SortVariantVector avarQuick, Null Debug.Print DebugTimerOff DebugTimerOn SortVariantVector avarQuick, Null Debug.Print DebugTimerOff Debug.Assert IsVariantVectorSorted(avarQuick, Null) = True Dim avarKeyCols() As Variant ReDim avarKeyCols(0 To 1) avarKeyCols(1) = 1 Dim avarMatrix() As Variant ReDim avarMatrix(0 To 1, 0 To UBound(avarOrig)) Dim lngCurFIle As Long For lngCurFIle = 1 To UBound(avarMatrix, 2) avarMatrix(1, lngCurFIle) = avarOrig(lngCurFIle) Next lngCurFIle Debug.Print "SortVariantMatrixRows Stable:" DebugTimerOn SortVariantMatrixRows avarMatrix, Null, avarKeyCols, True Debug.Print DebugTimerOff DebugTimerOn SortVariantMatrixRows avarMatrix, Null, avarKeyCols, True Debug.Print DebugTimerOff For lngCurFIle = 1 To UBound(avarMatrix, 2) avarMatrix(1, lngCurFIle) = avarOrig(lngCurFIle) Next lngCurFIle Debug.Print "SortVariantMatrixRows Non-stable:" DebugTimerOn SortVariantMatrixRows avarMatrix, Null, avarKeyCols, False Debug.Print DebugTimerOff DebugTimerOn SortVariantMatrixRows avarMatrix, Null, avarKeyCols, False Debug.Print DebugTimerOff End Sub
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.