On Mon, 10 Mar 2003, Thomas D. wrote:
> So after getting the array of hash references, is there a way to sort
> the array by a hash key, eg. key "color"?
It's in the perlfaq, and also in perldata IIRC.
--
"What were you doing?"
"He doesn't know."
"Know what?"
-- Agents Brown, J
At 3:49 PM +1100 3/11/03, Peter Skipworth wrote:
my @sorted_array = sort {$array[$a]->{color} cmp $array[$b]->{color} }
@array;
Rather,
my @sorted = sort { $a->{color} cmp $b->{color} } @array; # or maybe @$arrayref
--Ben
---
This sf.net emai
rch 11, 2003 3:37 PM
Subject: [htmltmpl] Sorting array of hash references
> Hello,
>
> I read HTML::Template tutorial at
> http://html-template.sourceforge.net/article.html. Before displaying any
data,
> I
> need to produce an array of hash references like:
> [
> { n
Hello,
I read HTML::Template tutorial at
http://html-template.sourceforge.net/article.html. Before displaying any data,
I
need to produce an array of hash references like:
[
{ name => 'Apple', color => 'Red',shape => 'Round' },
{ name => 'Orange', color => 'Orange', shape => 'Roun