From 6c609d9178a678e2b7c6fb6a17539fc8fe6500a0 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 17 Apr 2017 15:33:41 +0300 Subject: Sort incoming API data by id --- .gitignore | 3 ++- project/shoutboxapicommunicator.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bd41bb7..542476a 100644 --- a/.gitignore +++ b/.gitignore @@ -91,4 +91,5 @@ ENV/ # Vim swap files *.swp -.gitignore \ No newline at end of file +.gitignore +\.idea/ diff --git a/project/shoutboxapicommunicator.py b/project/shoutboxapicommunicator.py index b9e57b6..6655fd3 100644 --- a/project/shoutboxapicommunicator.py +++ b/project/shoutboxapicommunicator.py @@ -46,7 +46,8 @@ class ShoutboxCommunicator(BaseCommunicator): if len(content) > 0: logging.info("Messages from shoutbox:") - for msg in content: + sorted_content = sorted(content, key=lambda k: k["id"]) + for msg in sorted_content: logging.info("{}: {}, id: {}".format(msg["user"], msg["text"], msg["id"])) id_dec = int(msg["id"], 16) -- cgit v1.3