From eb039af9f28a51aa07f5dfc1a9d54976f0cb8162 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:51:43 +0100 Subject: [PATCH] Sort the modal data --- core/lib/threshold.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/lib/threshold.py b/core/lib/threshold.py index 51ac704..66984f6 100644 --- a/core/lib/threshold.py +++ b/core/lib/threshold.py @@ -23,6 +23,12 @@ def escape(obj): return obj +def sort_data(data): + for item in data: + if isinstance(data[item], list): + data[item].sort() + + def threshold_request(url, data): headers = { "ApiKey": settings.THRESHOLD_API_KEY, @@ -46,6 +52,7 @@ def threshold_request(url, data): response = r.json() except JSONDecodeError: logging.error(f"Invalid JSON response: {r.text}") + sort_data(response) return response