Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Flash/Flex > Flex
Flex Forum d'entraide sur la programmation Adobe Flex : applications Internet riches (RIA)
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 19/11/2010, 16h56   #1
Candidat au titre de Membre du Club
 
Inscription : septembre 2010
Messages : 67
Détails du profil
Informations personnelles :
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : septembre 2010
Messages : 67
Points : 14
Points : 14
Par défaut Quick Sort & array associatif

Bonjour,

J'ai ce code suivant qui fonctionne sur un array simple en (enlevant .keyword) mais je n'arrives pas à le faire fonctionner avec un array associatif...
Etant débutant, peut être pouvez vous m'aider
Il doit permettre de classer le tableau par taille (en nombre de caractère) de keyword.

Merci par avance

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
		public static function quickSort(list:Array):Array
		{
				// choose first element as pivot
				var pivot:String = list[0].keyword
 
				// slice of the pivot and keep them as rest
				var rest:Array = list.slice(1) 
 
				return(
						// sort all numbers…
						quickSort
						(
							// …that are less or equal than pivot…
							rest.filter
							(
								wrap
								( 
									greaterThan(pivot)
								)
							)
						)
 
						// …concatenate them with the pivot…              
						.concat
						(
							[pivot]
						)
 
						// …and concatenate all of the previous…
						.concat
						(
							// …with all sorted numbers…               
							quickSort
							(     
								// …that are greater than pivot.
								rest.filter
								(
									wrap
									( 
										lessOrEqualThan( pivot ) 
									) 
								)
							)
						)
					)
						/// return rest;
			}
 
 
 
 
		public static function lessOrEqualThan(value:String):Function
		{
			return(
				function( x:String ) : Boolean
				{
					return x.length <= value.length
				}
			)
		}
 
		public static function greaterThan(value:String):Function
		{
			return(
				function( x:String):Boolean
				{
					return x.length > value.length
				}
			)
		}
 
		public static function wrap( f:Function):Function
		{
			return(
					function( x : *, index : int, array : Array ) : *
					{
						return f( x )
					}
				)
		}
siriu est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 18h50.


 
 
 
 
Partenaires

Hébergement Web