If you're on linux/unix you could use the sort utility which will do that without you writing any code at all.
In reply to Re: Sorting in Perl by RichardK in thread Sorting in Perl by perlUser345