in reply to useless use of sort???

It would really help if you would show some sample input, not just the (undesired) output you're getting.