I like sorting an array of indices for stuff like that:
That way you can use an array slice to get each column in the "sorted" order. Though, with each record held in single anonymous array, it has little advantage (unless you wish to keep track of the "original" order for some reason).my @data= ([...],[...],...); my $idx= 3; my @idx= sort { $data[$a][$idx] <=> $data[$b][$idx] }, 0..$#data; for my $row ( @data[@idx] ) { for my $value ( @{$_} ) { ... } } # or print $q->table( map { $q->Tr( map { $q->td($_) } @{$_} ) } @data[@idx] );
As for figuring out complex data structure dereferencing syntax, I found that References Quick Reference made it so I never had any problems with that again.
- tye (but my friends call me "Tye")In reply to (tye)Re: Non-DB table sorting
by tye
in thread Non-DB table sorting
by Xaositect
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |