M
monkeys paw
I have an array of hashes like so:
$f = [ {
'file_name' => 'TakeTwo',
'id_type' => 'bill',
'id' => 'CA2005010A1',
},
{
'file_name' => 'steve',
'id_type' => 'bill',
'id' => 'CA2005000A3',
},
];
I want to sort by file_name.
I am trying this:
sort sort_by_filename @{$f};
sub sort_by_filename {
return $a->{file_name} cmp $b->{file_name}
}
This does not work. How would one do this??
$f = [ {
'file_name' => 'TakeTwo',
'id_type' => 'bill',
'id' => 'CA2005010A1',
},
{
'file_name' => 'steve',
'id_type' => 'bill',
'id' => 'CA2005000A3',
},
];
I want to sort by file_name.
I am trying this:
sort sort_by_filename @{$f};
sub sort_by_filename {
return $a->{file_name} cmp $b->{file_name}
}
This does not work. How would one do this??