Browse Source

generate-shortname-mapping: Sort resulting object

Danilo Bargen 6 years ago
parent
commit
d3816e8c3a
1 changed files with 7 additions and 5 deletions
  1. 7 5
      tools/twemoji/generate-shortname-mapping.py

+ 7 - 5
tools/twemoji/generate-shortname-mapping.py

@@ -6,12 +6,14 @@ GROUPS_JSON = '../../../twemoji-picker/generated/groups.json'
 with open(GROUPS_JSON, 'r') as f:
     groups = json.loads(f.read())
 
-print('const shortnames = {')
+mappings = []
+
 for emoji_list in groups.values():
     for emoji in emoji_list:
         for shortname in emoji['shortnames']:
-            print("    '{}': '{}',".format(
-                shortname.strip(':'),
-                emoji['codepoint_fully_qualified']
-            ))
+            mappings.append((shortname.strip(':'), emoji['codepoint_fully_qualified']))
+
+print('const shortnames = {')
+for (k, v) in sorted(mappings):
+    print("    '{}': '{}',".format(k, v))
 print('}')