NumPy allowed · plain Python earns 10 bonus points
Invert a key-to-value dictionary into a value-to-keys reverse index -- the basic logic behind building inverted indexes for search and grouping mappings.
Implement invert_dictionary(mapping): produce an inverted dictionary where each key is a distinct value from mapping, and its value is a sorted list of keys from mapping that held that value. If mapping is empty, return {}.
invert_dictionary(mapping: dict) -> dict