in reply to Size-limited, fitness-based lists

Have you considered something like this for your application?:

#! perl -slw use strict; sub bestN { my( $cmp, $n, $ref ) = @_; my $src = $ref; if( ref $ref eq 'ARRAY' ) { my $t = 0; $src = sub{ $t < @{ $ref } ? $ref->[ $t++ ] : undef }; } my $_cmp = sub { local( $::a, $::b ) = @_; $cmp->() }; my @top = sort $cmp map $src->(), 1 .. $n; while( defined( $_ = $src->() ) ) { next if $_cmp->( $top[ $#top ], $_ ) <= 0; my $p = $#top; while( $p > 0 ) { $_cmp->( $top[ --$p ], $_ ) <= 0 and last; } splice @top, $p, 0, $_; pop @top; } return @top; } my @in = 1 .. 100; print for bestN sub{ $::b <=> $::a }, 10, \@in; open DICT, '<', $ARGV[0] or die $!; print for bestN sub{ length( $::b ) <=> length( $::a ) }, 10, sub{ loc +al $^W; chomp( $_ = <DICT> ); $_ };;

Output:

C:\test>topN words.txt 100 99 98 97 96 95 94 93 92 91 abstractionisms abstractionists acanthocephalan acceptabilities acceptingnesses accessibilities acclimatization accommodatingly accommodational absorbabilities

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!