On Wed, 2004-06-30 at 16:08, Glenn Linderman wrote: > I can also imagine code like > > while ( sort @array ) > { > ... > last if ... ; > ... > } > > for large @array, I speculate that it might often be more efficient to > use an incremental sort than to do a full sort, and only use a fraction > of the results. Of course, it depends on the likelihood of using a > small fraction, so probably in cases like this a user hint should > determine whether to use a full sort, or an incremental sort. use Lazy::Sort; { tie my @Lazy => Lazy::Sort => sub($$){$_[0] cmp $_[1]} => @Array; local *_; while(defined ($_ = shift @Lazy)){ ... last if ... } ... } I'm about to post Lazy::Sort to p5p, enough of it to do that at least, encourage me to CPANify it and I expect I will. A better interface would be good though. -- david nicol "cat and buttered toast"Thread Previous | Thread Next