in reply to Re: Re: Re: reversing a sort...
in thread reversing a sort...

I quite intentionally did not say one would be always be "faster". I said reverse sort is less efficient. sort and reverse sort are both O(n log n), but the one with reverse has a larger constant factor and is less efficient.

By the way, if you want to know the fastest way to sort the list (1..100_000) in descending order, it's: reverse (1 .. 100_000); ;)

Update: Doh. As Tilly explains below, I totally messed up the Big O analysis. Anyway, there is an added inefficiency with reverse sort, that's my point. :)

Replies are listed 'Best First'.
Re (tilly) 5: reversing a sort...
by tilly (Archbishop) on May 09, 2001 at 05:23 UTC
    Actually the one with the reverse has the exact same constant factor as the regular sort.

    The additional inefficiency is O(n), not O(n log n). Plus it is O(n) with a fairly small factor...