From 8a0c9190a92fd4711fa54400a07ca16a1a6fb633 Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Tue, 24 Jun 2014 15:59:24 +0200 Subject: [PATCH] sort reported TLS session ticket hint using natural sort --- top1m/parse_results.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/top1m/parse_results.py b/top1m/parse_results.py index 40d85f6..ee3ca31 100644 --- a/top1m/parse_results.py +++ b/top1m/parse_results.py @@ -14,6 +14,12 @@ import json import sys from collections import defaultdict import os +import re + +def natural_sort(l): + convert = lambda text: int(text) if text.isdigit() else text.lower() + alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ] + return sorted(l, key = alphanum_key) report_untrused=False @@ -340,7 +346,7 @@ for stat in sorted(pfsstats): print("\nTLS session ticket hint Count Percent ") print("-------------------------+---------+--------") -for stat in sorted(tickethint): +for stat in natural_sort(tickethint): percent = round(tickethint[stat] / total * 100, 4) sys.stdout.write(stat.ljust(25) + " " + str(tickethint[stat]).ljust(10) + str(percent).ljust(9) + "\n")