On Mon, Mar 26, 2001 at 05:29:24PM -0500, John Porter wrote:
> Jarkko Hietaniemi wrote:
> > ST (or GR) applies to any situation where you your sort
> > comparator function isn't directly expressible with (Perl) primitives,
> > and worthwhile it is (like Yoda feel I) when the cost of converting
> > the keys (so that the primitives can again be employed) begins to
> > dominate the overall cost of sort().
> 
> Of course.  So how is the ST justified when you simply want to
> sort by length?  I.e., why is this not sufficient:

Those of the School of Maniacal Optimization may prefer calling
length() only O(N) times, instead of O(N log N) times.  Yeah, a weak
argument, but then again, I didn't claim length() as such being the
prime user of ST.  I just jumped at your "fields" description, which
sounded odd to me.  There need not be "fields" by any stretch of the
term.  It's all about reduction to primitive-comparable and the
relative cost of it.

>       sort { length($a) <=> length($b) } # I see no ST here.
> 
> And this was alleged to be the most common case for ST.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Reply via email to