From e2ffc356a804acb9f110198f95e4f9f75bf1ef81 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Wed, 27 Aug 2014 09:19:08 +0100 Subject: [PATCH] Sort output --- dropbot/bot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dropbot/bot.py b/dropbot/bot.py index c750519..3ef5741 100644 --- a/dropbot/bot.py +++ b/dropbot/bot.py @@ -481,7 +481,7 @@ class DropBot(ClientXMPP): return '!id ' char_name = ' '.join(args) - result = EVEAPIConnection().eve.CharacterID(names=char_name) + result = EVEAPIConnection().eve.CharacterID(names=char_name.strip()) if len(result.characters) == 0: return 'Unknown character {}'.format(char_name) char_name = result.characters[0].name @@ -490,6 +490,7 @@ class DropBot(ClientXMPP): headers, res = ZKillboard().characterID(char_id).kills().pastSeconds(60 * 60 * 24 * 7).get() from collections import defaultdict, Counter + from operator import itemgetter kill_types = defaultdict(int) ship_types = defaultdict(int) @@ -512,6 +513,6 @@ class DropBot(ClientXMPP): len(res), intcomma(sum_value), ', '.join(set([self.map.node[int(x['solarSystemID'])]['name'] for x in res])), - ', '.join(set(['{} ({})'.format(self.types[unicode(x)], y) for x, y in Counter(ship_types).most_common(5)])), - ', '.join(set([x for x, y in Counter(alli_assoc).most_common(5) if x.strip() != ''])) + ', '.join(set(['{} ({})'.format(self.types[unicode(x)], y) for x, y in sorted(Counter(ship_types).most_common(5), key=itemgetter(0))])), + ', '.join(set([x for x, y in sorted(Counter(alli_assoc).most_common(5), key=itemgetter(0)) if x.strip() != ''])) )