[EMAIL PROTECTED] wrote: > > Hi all, Hello,
> Is there an easy way to sort 2 arrays and keep the relating indices together. > for instance I have an array of times, and an array of emails. > I would like to give the user a choice of sorting by time(numeral) or > email(alpabetical); I would use an array of arrays to keep the two fields synced. # Array of Arrays @rows = ( [ email1 => time1 ], [ email2 => time2 ], ... [ emailn => timen ], ); # Sorting an Array of Arrays my @sorted; if ( $q->param( 'oldest' ) or $q->param( 'newest' ) ) { @sorted = sort { $a->[ 1 ] <=> $b->[ 1 ] } @rows; if ( $q->param( 'oldest' ) ) { @sorted = reverse @sorted; } } elsif ( $q->param( 'AtoZ' ) or $q->param( 'ZtoA' ) ) { @sorted = sort { $a->[ 0 ] cmp $b->[ 0 ] } @rows; if ( $q->param( 'ZtoA' ) ) { @sorted = reverse @sorted; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]