in reply to Need help with a script

man 1 sort. Or show some effort and post what Perl you've already written that's not working and explain what's not doing what you expect.

The cake is a lie.
The cake is a lie.
The cake is a lie.