The "requirement" is to support the business function - Not the tool used to reach the desired output.
If someone is so insistent that you must use your sort product, they need to provide the information you need to implement. . .
In order to implement using any tool or language, i believe the requirement needs to be more clearly presented. . . at least for me to understand.
First record of the output file has CONSULTANT from the last record key field has 111 and Basic salary fom input file
Why? Same question regarding the second record . . .
You should not implement a solution that you will have no idea how to maintain. . .