Dan Muey wrote:
> 
> Kevin Pfeiffer wrote:
> > 
> > BTW, doesn't 'sort -u' also sort the list?
> 
>  sort -u opens a file and prints to STDOUT or another file the unique lines,
> but that is an external command and not every server will necessariy have a
> sort command and if it does -u may have a different meaning or it may not
> exist at all.

If you have a list/file with a lot of duplicates then storing the list
as hash keys and sorting those hash keys will be a LOT faster then using
'sort -u' because 'sort -u' has to sort the entire list first before it
can remove duplicates while storing the list as hash keys removes the
duplicates first leaving a much smaller list to sort.  So for example if
you have a list of 10,000 items of which only 10 are unique, 'sort -u'
has to sort all 10,000 and then remove the duplicates while a perl hash
would only have 10 items to sort.  (Where the 'unique' part is O(n) and
the 'sort' part is usually O(n log n).)


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to