Suppose I have a file with a gazillion lines in it and I want to know 
which line would come out first if I were to sort the file.  It seems that 
GNU sort does not have that option.  Even better would be to have the 
option to put out the first k sorted lines of an n-line file (you'd get 
the last k by using the -r option).  Here's some info about algorithms:

http://en.wikipedia.org/wiki/Selection_algorithm

The idea is to *not* do this because of the massive computational demand:

sort file | head -$k
sort -r file | head -$k

That would give the right answer, though.  Is there anything that will do 
this sort of thing?  Usually the problem is to sort numbers and maybe 
awk/gawk will be good for that job:

http://www.google.com/search?q=awk+maximum+minimum

Maybe that works for non-numeric data, too, so long as only a single 
column of the input is of interest.  It would be good to have it pump out 
the entire line where the j-th column has the maximum or minimum value. 
I'm not sure how it would deal with ties -- probably by dropping all but 
one of them.

Anyway, this seems like a missing tool in the GNU coreutils.  If only we 
had one more sort option for doing this.

Mike