I think that you want to read A Fresh Look at Efficient Perl Sorting by Uri Guttman and Larry Rosler. It's the best paper out there that completely explains sort, especially sorting in Perl. There's also a companion module that you'll want to look at: Sort::Maker.