Quote Originally Posted by Nouyana View Post
Speed test. 10 000 rows.

VBFlexGrid1_Compare = 3199 ms (BubbleSort) Name:  machine-gun1.gif
Views: 5678
Size:  14.7 KB
MSHFlexGrid1_Compare = 61 ms Name:  stink.gif
Views: 5640
Size:  8.8 KB
VBFlexGrid1_CompareText = 10 ms. Brilliant! Name:  clapping.gif
Views: 5668
Size:  4.7 KB

Code:
Private Sub MSHFlexGrid1_Compare(ByVal Row1 As Long, _
                                 ByVal Row2 As Long, _
                                 Cmp As Integer)
   Dim Text1 As String
   Dim Text2 As String
   With MSHFlexGrid1
      Text1 = .TextMatrix(Row1, .Col)
      Text2 = .TextMatrix(Row2, .Col)
   End With

   Dim Lng1 As Long: Lng1 = CLng(Right$(Text1, Len(Text1) - 5&))
   Dim Lng2 As Long: Lng2 = CLng(Right$(Text2, Len(Text2) - 5&))
   Cmp = Sgn(Lng2 - Lng1)
End Sub

Private Sub VBFlexGrid1_Compare(ByVal Row1 As Long, _
                                ByVal Row2 As Long, _
                                ByVal Col As Long, _
                                Cmp As Long)
   Dim Text1 As String
   Dim Text2 As String
   With VBFlexGrid1
      Text1 = .TextMatrix(Row1, Col)
      Text2 = .TextMatrix(Row2, Col)
   End With

   Dim Lng1 As Long: Lng1 = CLng(Right$(Text1, Len(Text1) - 5&))
   Dim Lng2 As Long: Lng2 = CLng(Right$(Text2, Len(Text2) - 5&))
   Cmp = Sgn(Lng2 - Lng1)
End Sub

Private Sub VBFlexGrid1_CompareText(ByVal Text1 As String, _
                                    ByVal Text2 As String, _
                                    ByVal Col As Long, _
                                    Cmp As Long)
   Dim Lng1 As Long: Lng1 = CLng(Right$(Text1, Len(Text1) - 5&))
   Dim Lng2 As Long: Lng2 = CLng(Right$(Text2, Len(Text2) - 5&))
   Cmp = Sgn(Lng2 - Lng1)
End Sub
Update released.

VBFlexGrid1_Compare now uses a indirect MergeSort instead of BubbleSort. The indirect MergeSort is a bit slower than the normal one.
So I expect that VBFlexGrid1_Compare is now very fast compared to before but slower than VBFlexGrid1_CompareText.