[Solved] Split arrays into multiple arrays based on string characters [closed]


This is a compact version by using a closure for the sorted character array.

var array = ['car', 'incl', 'arc', 'linc', 'rca', 'icnl', 'meta', 'tame'],
    result = Object.values(
        array.reduce(
            (r, s) => (a => ((r[a] = r[a] || []).push(s), r))([...s].sort()),
            {}
        )
    );
    
console.log(result);

1

solved Split arrays into multiple arrays based on string characters [closed]