A
alwaysonnet
hi all,
I've got an array of hash-references as following. ( i've represented
hash-references as a table below)
Type A/C No Status(active/inactive)
Prefund 12345 Y
Prefund 45678 N
Receipt 78878 N
Receipt 32365 Y
Payment 56546 N
Payment 23456 N
Payment 34093 Y
I want to display all the active accounts (status with "Y") before
inactive accounts along with preserving the order by type ie., Prefund
should come first before Receipt and Payment along the order.
I've got the code which i've hard-coded the account type(Payment) and
then sorting according to their status.
foreach my $label(@accts) {
if ($label->{'batype'} eq "Payment") {
push(@acct_pay,$label);
}
}
foreach $x(@acct_pay) {
@sorted = sort { $b->{'baactive'} cmp $a->{'baactive'} } @acct_pay;
}
Is there any way of how to achieve this by sorting according to status
by preserving the account type order.
Thanks a ton,
Raj
I've got an array of hash-references as following. ( i've represented
hash-references as a table below)
Type A/C No Status(active/inactive)
Prefund 12345 Y
Prefund 45678 N
Receipt 78878 N
Receipt 32365 Y
Payment 56546 N
Payment 23456 N
Payment 34093 Y
I want to display all the active accounts (status with "Y") before
inactive accounts along with preserving the order by type ie., Prefund
should come first before Receipt and Payment along the order.
I've got the code which i've hard-coded the account type(Payment) and
then sorting according to their status.
foreach my $label(@accts) {
if ($label->{'batype'} eq "Payment") {
push(@acct_pay,$label);
}
}
foreach $x(@acct_pay) {
@sorted = sort { $b->{'baactive'} cmp $a->{'baactive'} } @acct_pay;
}
Is there any way of how to achieve this by sorting according to status
by preserving the account type order.
Thanks a ton,
Raj