Hi McUsrII.
Yes. The results from your script seem to be more consistent now. I see your |median|() handler now returns a list containing both the median value and the median position. My handler just returns the value.
Our interpretations of “median” agree where there are odd numbers of items, but my handler uses the “average of two middle values” convention when the number of items is even. (When putting it together, I wasted a lot of time trying to exploit the fact that the average of items k and -k works for both even and odd list sizes. But in the end, it proved simpler and faster to use different code for the two situations!)
I see your script uses randomised pivot choosing, presumably following the theory that this is likely to produce better pivots more often than always using, say, the values from the middle of the ranges ” and that therefore it’ll make the process faster. But in fact, as Arthur and I discovered when writing our original Quicksort implementation, any slight theoretical advantage is totally obliterated by the time it takes to make random choices in AppleScript! That’s why stuck with the middle values.