Hi Carlo,
I have been using a sort function based on J. L. Bentley and M. D.
McIlroy's "Engineering a sort function" from Software Practice and
Experience. This version goes to great lengths to avoid a "bad"
pivot, using Tukey's ninther and other means to improve performance.
This implementation swaps equal keys, which explains why FileChanged()
is triggered even when the final order remains the same.
I did some more research, and found that by using Niklaus Wirth's
version of quicksort published in "Algorithms + Data Structures =
Programs" (1976!), and by changing the pivot calculation from the
median of three to using a (fast: x ^= x << 17; x ^= x >> 13; x ^= x
<< 5) randomly generated index, the O(n**2) case is avoided. In my
tests, this change actually makes the sort faster than
Bentley/McIlroy's version, for TSE at least. Plus, Wirth's version
does not swap already ordered keys, which prevents the file from
changing if it is already in order.
I also added test cases to sanity2 to verify this actually works.
I'm using it now, and it will be in the next version.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
semware+u...@googlegroups.com.
> To view this discussion visit
https://groups.google.com/d/msgid/semware/000c01dcb5f9%2482d036c0%248870a440%24%40ecarlo.nl.