From 0120fff9bcbaf3ca8e6472f32d1ba84f2bcb7c7a Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Tue, 6 Sep 2016 14:08:06 +0200 Subject: [PATCH] sort CA's by count, not name --- top1m/parse_CAs.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/top1m/parse_CAs.py b/top1m/parse_CAs.py index 29812e0..619625e 100644 --- a/top1m/parse_CAs.py +++ b/top1m/parse_CAs.py @@ -19,6 +19,7 @@ import sys from collections import defaultdict import os from OpenSSL import crypto +from operator import itemgetter invocations = defaultdict(int) @@ -321,12 +322,12 @@ for stat in sorted(effective_security): print("\nRoot CAs Count Percent") print("---------------------------------------------+---------+-------") -for stat in sorted(root_CA): - percent = round(root_CA[stat] / total * 100, 4) - sys.stdout.write(stat.ljust(45)[0:45] + " " + str(root_CA[stat]).ljust(10) + str(percent).ljust(4) + "\n") +for stat, val in sorted(root_CA.items(), key=itemgetter(1), reverse=True): + percent = round(val / total * 100, 4) + sys.stdout.write(stat.ljust(45)[0:45] + " " + str(val).ljust(10) + str(percent).ljust(4) + "\n") print("\nIntermediate CA Count Percent") print("---------------------------------------------+---------+-------") -for stat in sorted(intermediate_CA): - percent = round(intermediate_CA[stat] / total * 100, 4) - sys.stdout.write(stat.ljust(45)[0:45] + " " + str(intermediate_CA[stat]).ljust(10) + str(percent).ljust(4) + "\n") +for stat, val in sorted(intermediate_CA.items(), key=itemgetter(1), reverse=True): + percent = round(val / total * 100, 4) + sys.stdout.write(stat.ljust(45)[0:45] + " " + str(val).ljust(10) + str(percent).ljust(4) + "\n")