#!/usr/bin/env python3
import json

GROUPS_JSON = '../../../twemoji-picker/generated/groups.json'

with open(GROUPS_JSON, 'r') as f:
    groups = json.loads(f.read())

print('const shortnames = {')
for emoji_list in groups.values():
    for emoji in emoji_list:
        for shortname in emoji['shortnames']:
            print("    '{}': '{}',".format(
                shortname.strip(':'),
                emoji['codepoint_fully_qualified']
            ))
print('}')

@@ -165,37 +165,22 @@
 ))%0A%0A
-print('const shortname
+mapping
 s = 
-%7B')
+%5B%5D%0A
 %0Afor
@@ -302,56 +302,25 @@
     
-print(%22    '%7B%7D': '%7B%7D',%22.format(%0A                
+mappings.append((
 shor
@@ -340,24 +340,8 @@
 :'),
-%0A               
  emo
@@ -371,29 +371,121 @@
 lified'%5D
-%0A            
+))%0A%0Aprint('const shortnames = %7B')%0Afor (k, v) in sorted(mappings):%0A    print(%22    '%7B%7D': '%7B%7D',%22.format(k, v
 ))%0Aprint

Sort resulting object