Page 1 sur 1

Structure - Trier une structure

Publié : mar. 04/oct./2011 11:01
par falsam
Trier une structure

Code : Tout sélectionner

;Trie d'une structure
Structure Potager
    Nom.s
    Famille.s
EndStructure

Dim MonPanier.Potager(4)
Dim CopieMonPanier.Potager(4)

MonPanier(0)\Nom="Pomme"
MonPanier(0)\Famille="Fruit"
MonPanier(1)\Nom="Concombre"
MonPanier(1)\Famille="Legume"
MonPanier(2)\Nom="Peche"
MonPanier(2)\Famille="Fruit"
MonPanier(3)\Nom="Tomate"
MonPanier(3)\Famille="Legume"
MonPanier(4)\Nom="Abricot"
MonPanier(4)\Famille="Fuit"


;Tri d'une structure
SortStructuredArray(MonPanier(), #PB_Sort_Ascending|#PB_Sort_NoCase, OffsetOf(Potager\Nom), #PB_Sort_String)


;Teste
For i=0 To 4
  Debug Monpanier(i)\Nom 
Next  
Note : PB 5.20+ Remplacer #PB_Sort_String par #PB_String