Having an issue with my code snippet below, My goal is to insert a new record at the beginning of the array and then sort it based on the label. However, I'm encountering an unexpected outcome where the array turns out empty.
const array = [{id: '3', name: 'name1'},
{id: '4', name: 'name2'},
{id: '5', name: 'name3'}]
const items = array
.map((sp) => ({ label: sp.name, value: sp.id }))
.splice(0, 0, { label: '', value: '' })
.sort((a, b) => a.label - b.label);
console.log(items);