Skip to content

Instantly share code, notes, and snippets.

Created December 13, 2012 11:28
Show Gist options
  • Save anonymous/4275855 to your computer and use it in GitHub Desktop.
Save anonymous/4275855 to your computer and use it in GitHub Desktop.
my $sorted_results = $results;
if ( $sortby eq 'reporter' )
{
$sorted_results = [
sort {
$order eq 'asc'
? $a->{$sortby} cmp $b->{$sortby}
: $b->{$sortby} cmp $a->{$sortby}
} @$results
];
}
else
{
$sorted_results = [
sort {
$order eq 'asc'
? $a->{$sortby} <=> $b->{$sortby}
: $b->{$sortby} <=> $a->{$sortby}
} @$results
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment