> itertools only looks for changes to the key value (the one returned by 
> operator.itemgetter(0) in your case); it doesn't sort the list for you.
> 
> this should work:
> 
>    for k, g in itertools.groupby(sorted(vals), operator.itemgetter(0)):
>       print k, [i for i in g]

footnote: to turn the contents in an iterator into a list object, 
list(g) is a bit more convenient than [i for i in g].

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to