Public Sub Quicksort(ByVal t() As Double, Optional ByVal loBound As Integer Integer.MaxValue, Optional ByVal upBound As Integer Integer.MinValue) ' http://www.visionduweb.com/cours/ipi/divers_net/Puissance_VB_Net.htm ' http://faq.vb.free.fr/index.php?question=151 Dim med_value As Double, hi As Integer, lo As Integer, i As Integer If loBound Integer.MaxValue Then loBound t.GetLowerBound(0) If upBound Integer.MinValue Then upBound t.GetUpperBound(0) If loBound >= upBound Then Exit Sub Dim op As New Random i = Convert.ToInt32(Int((upBound - loBound + 1) * op.NextDouble + loBound)) 'rnd fourni un aléatoire med_value t(i) : t(i) t(loBound) lo loBound : hi upBound Do Do While t(hi) >= med_value hi = hi - 1 : If hi <= lo Then Exit Do Loop If hi <= lo Then t(lo) = med_value : Exit Do End If t(lo) t(hi) : lo lo + 1 Do While t(lo) < med_value lo = lo + 1 : If lo >= hi Then Exit Do Loop If lo >= hi Then lo hi : t(hi) med_value Exit Do End If t(hi) = t(lo) Loop Quicksort(t, loBound, lo - 1) ' Recursive calls Quicksort(t, lo + 1, upBound) End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Sub SortByName(byref ArrayList as ArrayList ) Dim dict As New List(Of Object) dict = ArrayList.ToArray.ToList() Dim DictTrié As IEnumerable(Of Object) = dict.OrderBy(Function(x) x.name) ArrayList = New ArrayList(DictTrié.ToArray) End Sub