I have data from JSON using Data::Dumper that looks like the following when I -
print Dumper $json_response;
$VAR1 = {
'report' => [
{
'stat' => 1,
'timestamp' => '1360775722',
'status' => '"Active"',
'name' => '"09:15 am, 13 Feb, 2013"',
'id' => '200'
},
{
'stat' => 1,
'timestamp' => '1360775806',
'status' => '"Active"',
'name => '"09:16 am, 13 Feb, 2013"',
'id' => '199'
}
],
'username' => 'test'
};
Is this type of data a hash with anonymous array? I am able to grab each key, value doing:
foreach ( @{$json_response->{report}} ){
my %report;
$report{status} = $_->{status};
$report{id} = $_->{id};
print "CGGSID: $report{id}\n";
print "Status: $report{status}\n\n";
}
How would I sort the data by the 'id'? I know I can push the 'id' to an array and probably sort the array, but trying to see other, more efficient way for sorting this. Thank you!