def version_cmp(a, b):
    """These keys just look like version numbers to me...."""
ai = map(int, a.split('.'))
bi = map(int, b.split('.'))
return cmp(ai, bi)
for k in sorted(list(mydict.keys()), version_cmp):
    pass
Can I sort text by its numeric value in Python?