Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Tri dans un tableau en mémoire

2 réponses
Avatar
Al
Bonjour à tous,

j'ai stocké un tableau de valeurs (TabVal(2000) as double).
je voudrais les trier par ordre croissant

Y a t il une fonction dans Visual Basic ?
Comment faire ?

Merci pour votre aide
Al

2 réponses

Avatar
FS
Bonjour,

Rien de tout fait mais de nombreuses fonctions VBA existent.
Par exemple :

'============================ Sub ShellSort(DataArray())
'Myrna Larson, mpep
Dim ArrayValue As String
Dim Min As Long, Max As Long
Dim N As Long, h As Long
Dim i As Long, j As Long, p As Long

Min = LBound(DataArray)
Max = UBound(DataArray)
N = Max - Min + 1
h = 1
Do
h = h * 3 + 1
Loop While h <= N

Do
h = h 3
For i = Min + h To Max
ArrayValue = DataArray(i)
For j = i - h To Min Step -h
If DataArray(j) > ArrayValue Then
DataArray(j + h) = DataArray(j)
Else
Exit For
End If
Next j
DataArray(j + h) = ArrayValue
Next i
Loop While h > 1

End Sub 'ShellSort
'============================
D'autres solutions possibles ici :

http://frederic.sigonneau.free.fr/Tris.htm

FS
--
Frédéric SIGONNEAU
Modules et modèles pour Excel :
http://frederic.sigonneau.free.fr/

Al a écrit :
Bonjour à tous,

j'ai stocké un tableau de valeurs (TabVal(2000) as double).
je voudrais les trier par ordre croissant

Y a t il une fonction dans Visual Basic ?
Comment faire ?

Merci pour votre aide
Al



Avatar
JB
Bonsoir,

Le tri le + rapide (Quick sort de Hoare):

http://boisgontierjacques.free.fr/pages_site/TriQuickSort.htm

JB

On 19 déc, 15:06, "Al" wrote:
Bonjour à tous,

j'ai stocké un tableau de valeurs (TabVal(2000) as double).
je voudrais les trier par ordre croissant

Y a t il une fonction dans Visual Basic ?
Comment faire ?

Merci pour votre aide
Al