Jeg fandt lidt som du nok kunne bruge...
' Quicksort ->
http://www.vb-helper.com/howto_sorted_dir.htmlPublic Sub Vis_Kort(ByRef kortstak() As Integer)
Dim i As Integer
Dim farver As Variant
Dim valører As Variant
farver = Array("Spar", "Klør", "Ruder", "Hjerter")
' Her bliver man nødtil at tilføje et 0 forand tal som er mindre end 10
valører = Array("02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14")
ReDim arrSort(UBound(kortstak)) As String
For i = 0 To UBound(kortstak)
arrSort(i) = farver(kortstak(i) Mod 4) & " " & valører(kortstak(i) Mod 13)
Next
' Sortering..
Call Quicksort(arrSort, 0, UBound(kortstak))
' Udskriver test ;)
List1.Clear
For i = 0 To UBound(arrSort)
List1.AddItem arrSort(i)
Next
End Sub
Private Sub Quicksort(list() As String, ByVal min As Long, ByVal max As Long)
Dim mid_value As String
Dim hi As Long
Dim lo As Long
Dim i As Long
' If there is 0 or 1 item in the list,
' this sublist is sorted.
If min >= max Then Exit Sub
' Pick a dividing value.
i = Int((max - min + 1) * Rnd + min)
mid_value = list(i)
' Swap the dividing value to the front.
list(i) = list(min)
lo = min
hi = max
Do
' Look down from hi for a value < mid_value.
Do While list(hi) >= mid_value
hi = hi - 1
If hi <= lo Then Exit Do
Loop
If hi <= lo Then
list(lo) = mid_value
Exit Do
End If
' Swap the lo and hi values.
list(lo) = list(hi)
' Look up from lo for a value >= mid_value.
lo = lo + 1
Do While list(lo) < mid_value
lo = lo + 1
If lo >= hi Then Exit Do
Loop
If lo >= hi Then
lo = hi
list(hi) = mid_value
Exit Do
End If
' Swap the lo and hi values.
list(hi) = list(lo)
Loop
' Sort the two sublists.
Quicksort list, min, lo - 1
Quicksort list, lo + 1, max
End Sub