diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2017-04-17 15:33:41 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2017-04-17 15:33:41 +0300 |
| commit | 6c609d9178a678e2b7c6fb6a17539fc8fe6500a0 (patch) | |
| tree | c425b85ccfef432e85491950228858560aa1cb91 | |
| parent | d0cd0d94453701235b732fefd63c45e906a15128 (diff) | |
Sort incoming API data by id
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | project/shoutboxapicommunicator.py | 3 |
2 files changed, 4 insertions, 2 deletions
@@ -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) |
