blob: ad6f38c25fd9c595d5e5512ea0bdeb31806a7e07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import json, sys
from collections import OrderedDict
input_filename = sys.argv[1]
output_filename = 'sorted_output.json'
with open(input_filename, 'r', encoding='utf-8') as f:
data = json.load(f)
sorted_data = OrderedDict(sorted(data.items(), key=lambda item: item[0].lower()))
with open(output_filename, 'w', encoding='utf-8') as f:
json.dump(sorted_data, f, ensure_ascii=False, indent=2)
print(f"Sorted JSON saved to '{output_filename}'")
|