in reply to Array Cleaning

Why not just map the defined array values to a hash as keys and then sort numerically? Takes care of duplicates, the sort is fast, and order is retained...not sure how it scales with input size compared with grep though.
@array = sort {$a <=> $b} keys (%hash = map { $_ => 1 } @array);

Replies are listed 'Best First'.
Re: Re: Array Cleaning
by Anonymous Monk on May 02, 2003 at 17:42 UTC
    nevermind. idea is ok but untested code sucks. my bad. wallowing in shame. Forget I said anything. :)