2009/10/30 Jim Gibson <jimsgib...@gmail.com>:
> Approach 1. is called a "stable sort". As you can see, Perl's sort gives you
> a stable sort, as the last two lines are in the order they appear in the
> original file. The Unix sort is not stable, so the lines with equal keys get
> reversed in the output. Whether or not you consider this a "bug" depends
> upon your application. You can generate a stable sort with the -s option to
> Unix sort (may depend upon your version).

Note also that unix sort(1) provides this behaviour through the -s
switch. So you have already emulated "sort -s" through perl!

Philip

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to