From 4821414846208e554c81c0a760224b044ca1350b Mon Sep 17 00:00:00 2001 From: Costa Shulyupin Date: Tue, 7 Aug 2018 08:05:52 +0300 Subject: [PATCH] +sort_dict --- srcxray.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/srcxray.py b/srcxray.py index 3cbde7e..f881bd4 100755 --- a/srcxray.py +++ b/srcxray.py @@ -419,6 +419,10 @@ def leaves(dg): return {n: dg.in_degree(n) for (n, d) in dg.out_degree if not d} +def sort_dict(d): + return [a for a, b in sorted(d.items(), key=lambda k: k[1], reverse=True)] + + def most_used(dg, ins=10, outs=10): # return {a: b for a, b in sorted(dg.in_degree, key=lambda k: k[1]) if b > 1 and} # return [(x, dg.in_degree(x), dg.out_degree(x))