On Jan 22, 1:58 pm, Gilles Ganault <nos...@nospam.com> wrote: > On 22 Jan 2010 13:35:26 GMT, Neil Cerutti <ne...@norwich.edu> wrote: > > >Resorting is more work than is needed. Just choose a different > >starting index each time you display the names, and set up your > >lister to wrap-around to your arbitrary starting index. > > Thanks. In this case, it means that in each loop iteration, I must > search the list to find which item starts with the letter I'd like to > begin sorting, eg. "B". Does Python include a search method or do I > have to use a for loop to locate this starting item?
How about a deque of lists... untested from collections import deque; from itertools import groupby deq = deque(list(items) for key, items in groupby(sorted(usernames), lambda L: L[0].upper())) Then everytime you use deq, rotate it? hth Jon. -- http://mail.python.org/mailman/listinfo/python-list