in reply to Perl sorting unique values
When you want to find the unique entries in (especially) a large collection of items, first you sort it, then you walk through the list to fetch the unique items. (Thanks to the sort, all duplicate items are adjacent.) You cannot, AFAIK, do this in just one step, unless the sort-utility or package that you are using provides that option.
TMTOWTDI, of course. Memory-based tricks such as hash-tables are certainly fine up to a point. The sort-then-uniq strategy will handle data of any quantity and will do so with linear performance.
Existing CPAN packages, as mentioned, are always to be looked-for first. (No matter what you’re doing, it has been done before.)
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl sorting unique values
by BrowserUk (Patriarch) on Jun 22, 2011 at 17:01 UTC | |
by pr09 (Novice) on Jun 23, 2011 at 05:38 UTC | |
by pr09 (Novice) on Jun 23, 2011 at 08:06 UTC |