Binary search for faster window stats

"in-place" AKA "incremental sorting"

Old code wasted time to do a full sort:

http://en.wikipedia.org/wiki/Quicksort
full sort is, on average: O(n log n)
with a worst case of "quadratic time"

http://en.wikipedia.org/wiki/Binary_search_algorithm
the new incremental sort is O(log n)
AKA logarithmic time, so much faster.

algorithm coded 2014 June 13 -- kuzetsa