in reply to Data Structure advice

If you're familiar with SQL, it might help to transform the data to CSV format and use DBD::CSV to sort (or group) using a SELECT statement.

Hope this helps, -gjb-