Ok, looks like secondary IE's are not bound to primary, but tertiary's are bound to secondary? If so, you need to read in each primary and secondary. When you find a tertiary, you'll want to have an array (or similar) tied to that corresponding secondaryIE. Now you can sort each independently. It's more about reading in and data structures than sorting. For instance:
Semi-Pseudo-Untested-code:
while ( <FILE> ) {
if ( isPrimary() ) {
push @primary, $_;
} elsif ( isSecondary() ) {
push @secondary, $_;
} elsif ( isTertiary() ) {
push @{$secondary[$#secondary]}, $_;
}
}
@primary = sort { $a cmp $b } @primary;
@secondary = sort { $a cmp $b } @secondary;
foreach $secondaryItem ( @secondary ) {
@{$secondaryItem} = sort { $a cmp $b } @$secondaryItem;
}
Something like that - anyways, don't forget to use strict :)
--------------
It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs