This SEEMS to work, but I feel like i'm missing something.
VB Code:
Private Sub SortCollection(ByRef collectionname As EntryCollection) For i As Integer = 1 To collectionname.Count For j As Integer = 2 To collectionname.Count If CType(collectionname(j), Entry).Filesize >= CType(collectionname(j - 1), Entry).Filesize Then collectionname.Swap(j, j - 1) End If Next Next End Sub
(and here is the swap function out of my EntryCollection Class)
VB Code:
Public Sub Swap(ByVal FirstMember As Integer, ByVal SecondMember As Integer) Dim temp As Object = List(FirstMember - 1) List(FirstMember - 1) = List(SecondMember - 1) List(SecondMember - 1) = temp End Sub
The type Entrycollection contains various enums and structures, the one being used in this case is the "Entry" type (which is where the Ctype statements come in)
Also, this seems like it would get REALLY slow with lots of members to sort, since it basically runs through the loop (number of members)^2 times.
Any other sorting methods that are faster, or theories in general?
Bill




Reply With Quote