Please Help me in GRUSORT

Please anybody tell me the approach to solve the GRUSORT .Please explain in detail.
problem link

Check out my answer to another question about this problem. Hope it helps