I have the array of objects: the cars with the data. And I have a given sorted array of objects – these cars sorted by colors (red, black, other) and nested inside. Here you can take a look: JSFiddle - Two Arrays, unsorted and sorted
Which array method is better to use to create something like that? And I wouldn't like to mutate the given array.
    const unsortedCars = [
    {
        id: 3,
        seller: 'Anna',
        dataPublished: 'date',
        carData: {
            id: 3,
            color: 'red',
            is_sport: false,
        },
    },
    {...},
];
const sortedCarsByColors = [
    {
        color: 'red',
        cars: [
            {
                id: 3,
                seller: 'Anna',
                dataPublished: 'date',
                carData: {
                    id: 3,
                    color: 'red',
                    is_sport: false,
                },
            },
            {...},
        ],
    },
];
 
    