in reply to Rule-based sorting

This will be an easy task if you read the sorting section in the book "Data Munging with Perl."