C
ccc31807
I have a reference to a hash defined like this:
$chpr->{$college}{$dept}{$rank}{$fac_id}{$subj} = {
...,
sort_name = $sort_name,
...};
I print an Excel report like this:
#open Excel workbook for COLLEGE
foreach my $college (sort keys %{$chpr}) {
foreach my $dept (sort keys %{$chpr->{$college}}) {
foreach my $rank (sort keys %{$chpr->{$college}{$dept}}) {
#open new worksheet for DEPARTMENT
foreach my $fac_id (sort keys %{$chpr->{$college}{$dept}{$rank}}) {
foreach my $subj (sort keys %{$chpr->{$college}{$dept}{$rank}{$fac_id}}) {
#$worksheet->write_row($row, $col, $arrayref);
#here, I would like to alphabetically sort by
#$chpr->{$college}{$dept}{$rank}{$fac_id}{$subj}{sort_name}
#so that the faculty names appear in alphabetical order listed
#by college, department, rank, and subject (faculty ID isn't wanted)
}
}
}
}
}
I can't see the $subj from $fac_id, and once I get to $subj, the has is already sorted by $fac_id. I can't figure out a way to retroactively unsort by $fac_id and sort by ...{$fac_id}...{sort_name}.
Ordering the faculty by sort_name isn't possible because sort_name is not unique, but fac_id is unique.
Suggestions? Other than rewriting the whole thing?
Thanks, CC.
$chpr->{$college}{$dept}{$rank}{$fac_id}{$subj} = {
...,
sort_name = $sort_name,
...};
I print an Excel report like this:
#open Excel workbook for COLLEGE
foreach my $college (sort keys %{$chpr}) {
foreach my $dept (sort keys %{$chpr->{$college}}) {
foreach my $rank (sort keys %{$chpr->{$college}{$dept}}) {
#open new worksheet for DEPARTMENT
foreach my $fac_id (sort keys %{$chpr->{$college}{$dept}{$rank}}) {
foreach my $subj (sort keys %{$chpr->{$college}{$dept}{$rank}{$fac_id}}) {
#$worksheet->write_row($row, $col, $arrayref);
#here, I would like to alphabetically sort by
#$chpr->{$college}{$dept}{$rank}{$fac_id}{$subj}{sort_name}
#so that the faculty names appear in alphabetical order listed
#by college, department, rank, and subject (faculty ID isn't wanted)
}
}
}
}
}
I can't see the $subj from $fac_id, and once I get to $subj, the has is already sorted by $fac_id. I can't figure out a way to retroactively unsort by $fac_id and sort by ...{$fac_id}...{sort_name}.
Ordering the faculty by sort_name isn't possible because sort_name is not unique, but fac_id is unique.
Suggestions? Other than rewriting the whole thing?
Thanks, CC.