techie411 has asked for the wisdom of the Perl Monks concerning the following question:
Is this type of data a hash with anonymous array? I am able to grab each key, value doing: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' };
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!foreach ( @{$json_response->{report}} ){ my %report; $report{status} = $_->{status}; $report{id} = $_->{id}; print "CGGSID: $report{id}\n"; print "Status: $report{status}\n\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting complex data
by davido (Cardinal) on Feb 13, 2013 at 19:47 UTC | |
|
Re: Sorting complex data
by duelafn (Parson) on Feb 13, 2013 at 22:43 UTC | |
|
Re: Sorting complex data
by locked_user sundialsvc4 (Abbot) on Feb 13, 2013 at 20:18 UTC |