sharktide/tools / order.py
sharktide's picture
download
raw
722 Bytes
import json
from pathlib import Path
filename = Path(__file__).resolve().parent.parent / "src" / "models" / "text.json"
# 1. Load your JSON data
with open(filename, "r", encoding="utf-8") as file:
data = json.load(file)
# 2. Target the nested "overrides" array and sort it by the "id" key
if "overrides" in data and isinstance(data["overrides"], list):
data["overrides"] = sorted(
data["overrides"],
key=lambda x: str(x.get("id", "")).lower()
)
# 3. Save the sorted data directly back into the same file
with open(filename, "w", encoding="utf-8") as file:
json.dump(data, file, indent=4, ensure_ascii=False)
print(f"Successfully alphabetized the 'overrides' list inside {filename}!")

Xet Storage Details

Size:
722 Bytes
·
Xet hash:
ebecdbe63d8ea8e99350bb1c11e2246d9dabe3bab8f2745be8b165046254a0ce

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.