Sort classes by fully qualified name. In the common case where you are

displaying a set of classes from one module it doesn't matter, but if you
are displaying a large class tree from multiple modules it improves the
display to sort by module.name.
This commit is contained in:
Skip Montanaro 2004-09-20 15:40:38 +00:00
parent 729d47db09
commit 41f89a4f3d

View File

@ -557,7 +557,8 @@ def getsource(object):
def walktree(classes, children, parent):
"""Recursive helper function for getclasstree()."""
results = []
classes.sort(key=attrgetter('__name__'))
classes.sort(lambda a, b: cmp("%s.%s" % (a.__module__, a.__name__),
"%s.%s" % (b.__module__, b.__name__)))
for c in classes:
results.append((c, c.__bases__))
if c in children: