-
SGrid 2.0 Sorting
Hello guys,
I'm using the SGrid from vbaccelerator in a project and I found in the own site a sorting code which seems to be very fast, check the link:
http://www.vbaccelerator.com/home/VB...ak13703-13.asp
Code:
Friend Sub QSortItems( _
ByRef vItems() As tGridCell, _
ByRef tRows() As tRowPosition)
quickSort vItems, tRows, 1, UBound(vItems, 2), UBound(vItems, 1)
End Sub
Code:
Private Sub quickSort( _
ByRef vItems() As tGridCell, _
ByRef tRows() As tRowPosition, _
l0 As Long, _
r0 As Long, _
NbColonnes As Long)
Dim l As Long
Dim r As Long
Dim vSortItems() As tGridCell
Dim iCol As Long
If r0 > l0 Then
l = l0
r = r0
ReDim vSortItems(1 To NbColonnes)
For iCol = 1 To NbColonnes
LSet vSortItems(iCol) = vItems(iCol, (l0 + r0) / 2)
Next iCol
While l <= r
While (l < r0) And pbGreater(vItems(), vSortItems(), l)
l = l + 1
Wend
While (r > l0) And Not pbGreater(vItems(), vSortItems(), r)
r = r - 1
Wend
If l <= r Then
If l <> r Then Echange vItems, tRows, l, r, NbColonnes
l = l + 1
r = r - 1
End If
Wend
If r > l0 Then quickSort vItems, tRows, l0, r, NbColonnes
If l < r0 Then quickSort vItems, tRows, l, r0, NbColonnes
End If
End Sub
My question is, how do can we implement it? :confused:
Regards