> Are you sure it's a HashOfArrays and not an ArrayOfHashes? > > #HAO > > $data{$key} = ['Jenda', 'Krynicky', '[EMAIL PROTECTED]', ...] > > # AOH > $data[$i] = {fname => 'Jenda', lname => 'Krynicky', email => > '[EMAIL PROTECTED]', ...} >
What I have now is something like this : @ID = qw (Foo Bar Blaz Bob); @Country = qw (UK US HK HK); @Gender = qw (F M M F); %table{ID} = (ID => \@ID, Country => \@Country, Gender => \@Gender); So I got $table{ID}[1] as 'Bar", and I think this is HOA. Note : The above array is always same in dimension, and the reading way is Foo's location is in UK and gender is F. This is fixed, so I can't modify anything on it. But what I going to do is like this : my %newTable = SortTable ( TABLE => \%table, Seq => "Gender=A, Country=D, ID=A"); my %newTable = SortTable ( TABLE => \%table, Seq => "ID=A, Gender=A, Country=A"); # where =A =D is in terms of acending and decending order. That would really complex if have to write one, so I am looking if there is an existed module for this. > Keep in mind that hash is not ordered! As illustrated, the order is always dynamic by different Seq, so that's not important here. > If you want to sort the AOH using a field you can do it like this: > > @sorted_data = sort {$a->{$key} cmp $b->{$key}} @data; > #ascending but how about HOA ? > where $key is the name of the field you want to use. > If you want to sort using several fields you can do it like this: > > @sorted_data > = sort {$a->{$key1} cmp $b->{$key1} or $a->{$key2} cmp $b->{$key2}} > @data; Poor me :-< I don't really understand the meaning of "or $a->{$key2} com $b->{$key2}}" here... Would any hints given here ? Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]