sort a report file having header and footer

I am having report file with header and footer . The details in between header and footer are separated by a pipe charater. I want to sort the file by considering multiple columns in between header and footer.

pls help

None of your previous threads with extremely similar questions gave you any ideas?

What you have you tried so far?

Example input & output?

MNM PRIVATE LIMITED
REPORT GENERATED ON 25.11.2011
CONSOLIDATION REPORT
--------------------------------------
NAME | EMPID | PLACE | RANK | SALARY|
--------------------------------------
A1 |121 | AP | 19 |2000 |
A2 |125 | KA | 11 |12000 |
A3 |129 | GJ | 16 |2000 |
A4 |127 | CHE | 81 |8000 |
A5 |126 | DEL | 61 |5000 |
A6 |120 | KA | 21 |5000 |
A7 |128 | AP | 10 |2000 |
A8 |123 | AP | 91 |2000 |
--------------------------------------
tOTAL |38000 |
--------------------------------------

I am having report file with header and footer . The details in between header and footer are separated by a pipe charater. I want to sort the file by considering multiple columns in between header and footer.

The report file is given below

   MNM PRIVATE LIMITED

REPORT GENERATED ON 25.11.2011
CONSOLIDATION REPORT
--------------------------------------
NAME | EMPID | PLACE | RANK | SALARY|
--------------------------------------
A1 |121 | AP | 19 |2000 |
A2 |125 | KA | 11 |12000 |
A3 |129 | GJ | 16 |2000 |
A4 |127 | CHE | 81 |8000 |
A5 |126 | DEL | 61 |5000 |
A6 |120 | KA | 21 |5000 |
A7 |128 | AP | 10 |2000 |
A8 |123 | AP | 91 |2000 |
--------------------------------------
tOTAL|38000 |
--------------------------------------

I have to sort above based on empid,rank,salary

pls help

This makes some assumptions about the report format. Should work if it is as you indicated in your sample.

awk '
    BEGIN {
        sort = "sort -t \\| -k 2n,2 -k 4n,4 -k 5n,5"
    }
    /------/ {                  # use dashes to determine records to sort
        if( ++snarf > 2 )
        {
            close( sort );
            snarf = -1;
        }
        print;
        next;
    }
    {
         if(  snarf > 1 )
              print |sort;
          else
              print;
   }
' input-file