How to deconstruct an array and put it into the “main” array?

How can i deconstruct an array, and put it into the array which is getting mapped on, then continue sorting on that?

Basicly the array looks the following after filtering it:

[

[‘traitName’, ‘value’],

[‘traitName’, [‘value01’, ‘value02’, ‘value03’ …]
],

]

What i want to do is check every trait, and check if the first index is an array, then deconstruct that, and put it into this array like this:

[

[‘traitName’, ‘value’],

[‘traitName’, value01],

[‘traitName’, value02],

[‘traitName’, value03],

..
],

]

Then i can continue sorting on this array.

 Object.entries(nft)
                .filter((val: any) => val[0] !== 'Attributes' && data.attributes[val[0]] !== undefined)
                .sort((a: any, b: any) => {
                  if (typeof a[1] === 'number') return Infinity;
                  return (
                    data.attributes[a[0]]?.values[a[1]]?.distribution - data.attributes[b[0]]?.values[b[1]]?.distribution
                  );
                })

I need to this between the filter and sorting i think.