It sounds like homework for sure, but I guess it is ok to give pointers, as long as it serves that he learns somehting.
In this spirit:
Unix/Linux has a tools approach to problems, which means that there are lot of small programms which can be added together (with pipes for example) to solve more complex problems, in this case I would advise that you look at sort(1).
Another good read about bash scripting is the "Advanced Bash-Scripting Guide" (http://www.tldp.org/guides.html#abs
) at the
linux documentation project (http://www.tldp.org