in reply to 2 dimensional array sorting...

You could do what you want with a one dimensional array, just treat the line as a whole. Dont split at the comma, until you are ready to output a group or an item. e.g.

open(FILE, $name) or die "orrible death $!"; my @data = sort (<FILE>);

The lines are now in the array in alpha order, and you can operate on the array with split etc without needing to be worried about the extra dimension.

For output you could write some sub's for output_group, output_item, output_group_number etc