Skip to content

Instantly share code, notes, and snippets.

@ZeldaZach
Last active July 8, 2020 15:16
Show Gist options
  • Select an option

  • Save ZeldaZach/5fe19930966a0e128f4e3739c8c839d6 to your computer and use it in GitHub Desktop.

Select an option

Save ZeldaZach/5fe19930966a0e128f4e3739c8c839d6 to your computer and use it in GitHub Desktop.
import json
import pathlib
if __name__ == "__main__":
custom_order = {"mythic": 0, "rare": 1, "uncommon": 2, "none": 3}
path = pathlib.Path("mtgjson-website/docs/.vuepress/public/resources/supporters.json")
with path.open() as f:
content = json.load(f)
for key in content.keys():
content[key] = sorted(content[key], key=lambda x: (custom_order[x.get("tier", "none")], "image" not in x, x["name"].lower()))
with path.open("w") as f:
json.dump(content, f, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment