From 41f89a4f3dd38d0f09be4586769a1f5b922402c8 Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Mon, 20 Sep 2004 15:40:38 +0000 Subject: 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. --- Lib/inspect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/inspect.py b/Lib/inspect.py index 5e3f7e2..101c7ec 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -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: -- cgit v0.12