PythiloMedium · 20 min · Task 9 of 20 · progress kept in this browser

Group by letters

Two words belong together if one is a rearrangement of the other's letters, ignoring case. Group a list of words this way.

group_by_letters(
    ["stone", "cat", "notes", "act"])
# [["stone", "notes"], ["cat", "act"]]

Groups appear in the order their first word appears, and words stay in their original order within a group.

Your task

Write group_by_letters(words) returning a list of groups as described. The word's original spelling is kept in the output.