>It's faster on my system because d.keys() is already sorted. But that may not be the case on other versions of python.< In my version it's a little slower. But what system are you using where keys is already sorted? IronPython maybe? Bye, bearophile