On 2010-01-22, Steven D'Aprano <st...@remove-this-cybersource.com.au> wrote: >> O(N*Log N) + O(N) == O(N**2)? > > Oops! :( > > Of course, the sort is in fast C, and the linear search is in > relatively slow Python, so it is quite conceivable that for > realistic amounts of data, the time could be dominated by the > searching. > > Or the OP might just change his requirements and allow starting > the display in the middle of the letter.
That's what I would advocate. The scheme of starting at a random (or cycling through) first letters still grants an arbitrary advantage to some user names. A random starting position is thus more fair *and* more efficient. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list