Those so similar and ugly sorting blocks can be generated from metadata, specially if you use some sorting module from CPAN as
Sort::Key or
Sort::Maker:
# untested!
use Sort::Key;
my %key_type = (CollectionId => 'int',
Framecount => 'int',
Status => 'str',
Missing => 'int',
Modified => 'str');
my %order = (collection => [qw(-CollectionId -Modified)], # the minus
framecount => [qw(-Framecount -Modified)], # sign means
status => [qw(Status -Modified)], # descending
+ order
missing => [qw(-Missing -Modified)],
modified => [qw(-Modified)]);
my %sorter;
for my $order (keys %order) {
my @types;
my @keys;
for (@{$order{$order}}) {
/^(-?)(\w+)$/ or die;
push @types, "$1$key_type{$2}";
push @keys, $2;
}
$sorter{$order} = Sort::Key::multikeysorter { @{$_}{@keys} } @types;
}
sub printCollectionData {
...
# Sort the collection according to orderBy param
@sortedCollectionData = $sorter{$orderBy}->(@collectionData);
...
}