Solución
solution.tsTypeScript
export function groupAnagrams(words: string[]): string[][] {
let result = []
for(let i = 0; i < words.length; i++) {
let current = words[i].split('').sort().join('')
let group = []
for(let j = 0; j < words.length; j++){
if(current === words[j].split('').sort().join('')) group.push(words[j])
}
const exists = result.some(item => JSON.stringify(item) === JSON.stringify(group));
if (!exists) result.push(group);
}
return result.map((v) => v.sort()).sort();
}0respuestas