Skip to content
Junior–Middle+161 views

Building groups of anagrams from a list of words

Task condition

Given a list of strings, it is necessary to collect all anagram words into separate subarrays, for example: [["вертикаль", "компактер"], ["апельсин", "спанислы"], ...]

As an example array, use the following dataset:


const arr = [
    "вертикаль",
    "компактер",
    "апельсин",
    "спанислы",
    "австралистик",
    "ватерполистка",
    "кластер",
    "стансер",
    "стража",
    "корибль"
];

It is required to write a function that takes such an array and returns an array of arrays, where each inner array contains anagrams. The order of groups and the order of words within groups are not important.

Frontend tasks in the code trainer