Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: Joe am 20.05.03 - 16:20:05

Titel: Sortierte Zahlenliste
Beitrag von: Joe am 20.05.03 - 16:20:05
Hi liebe Notes-Gemeinde,

ich habe - mal wieder - ein Problem, das ich nicht lösen kann. In einer Maske habe ich ein Feld, das eine Zahlenliste enthält. Diese Zahlenliste ist willkürlich, ich brauche sie aber aufsteigend sortiert. Diese neue Liste soll entweder den alten Feldinhalt ersetzen oder in ein neues Feld geschrieben werden, das ist mir egal.

Ist mir noch zu helfen???

Joe
Titel: Re:Sortierte Zahlenliste
Beitrag von: klaussal am 20.05.03 - 16:48:17
... suche mal nach quicksort
Titel: Re:Sortierte Zahlenliste
Beitrag von: Joe am 20.05.03 - 17:20:26
Quicksort ist prime, aber das sortiert meines Wissens nur alphanumerisch. Ich brauche aber eine numerische Sortierung, da es sich um Zahlen handelt  ???
Titel: Re:Sortierte Zahlenliste
Beitrag von: Till_21 am 20.05.03 - 18:08:30
kommt aufs quicksort an, oder  ;) ;)

hinter dem begriff versteckt sich nur ein algorithmus...


das hier hab ich mal gefunden ->

Public Sub QuickSortVariants(vArray As Variant, inLow As Long, inHi As Long)
     
   Dim pivot   As Variant
   Dim tmpSwap As Variant
   Dim tmpLow  As Long
   Dim tmpHi   As Long
   
   tmpLow = inLow
   tmpHi = inHi
   
   pivot = vArray((inLow + inHi) \ 2)
 
   While (tmpLow <= tmpHi)
 
      While (vArray(tmpLow) < pivot And tmpLow < inHi)
         tmpLow = tmpLow + 1
      Wend
     
      While (pivot < vArray(tmpHi) And tmpHi > inLow)
         tmpHi = tmpHi - 1
      Wend

      If (tmpLow <= tmpHi) Then
         tmpSwap = vArray(tmpLow)
         vArray(tmpLow) = vArray(tmpHi)
         vArray(tmpHi) = tmpSwap
         tmpLow = tmpLow + 1
         tmpHi = tmpHi - 1
      End If
   
   Wend
 
   If (inLow < tmpHi) Then QuickSortVariants vArray, inLow, tmpHi
   If (tmpLow < inHi) Then QuickSortVariants vArray, tmpLow, inHi
 
End Sub


gruss
Titel: Re:Sortierte Zahlenliste
Beitrag von: Joe am 21.05.03 - 10:01:29
Danke! Hat geklappt.