From 7bb5efd462ffe1ef80e13468a660a82e6987df81 Mon Sep 17 00:00:00 2001 From: Ivan Sagalaev Date: Thu, 17 Oct 2024 21:08:43 -0400 Subject: [PATCH] Sort the content case-insensitively before dumping to JSON --- code/dark_visitors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/dark_visitors.py b/code/dark_visitors.py index 484daa1..7d29c65 100644 --- a/code/dark_visitors.py +++ b/code/dark_visitors.py @@ -70,4 +70,6 @@ for section in soup.find_all("div", {"class": "agent-links-section"}): } print(f"Total: {len(existing_content)}") -Path("./robots.json").write_text(json.dumps(existing_content, indent=4, sort_keys=True)) \ No newline at end of file +sorted_keys = sorted(existing_content, key=lambda k: k.lower()) +existing_content = {k: existing_content[k] for k in sorted_keys} +Path("./robots.json").write_text(json.dumps(existing_content, indent=4)) \ No newline at end of file