I have an array that contains duplicate items. My goal is to filter out these duplicates and return only the unique items, sorted based on their frequency of occurrence in the initial array.
const initialArr = [
{
id: 1
},
{
id: 1
},
{
id: 2
},
{
id: 1
},
{
id: 3
},
{
id: 3
},
];
const expectedSortedResult = [
{
id: 1
},
{
id: 3
},
{
id: 2
}
]