Considering that I have an object like the following where it's possible to have many names and that 'The others' can appear at any index, how can I sort the array having 'The others' always as the first element and the rest of the names sorted in alphabetical order?
var friends = [
{ id: 1, name: 'Paul' },
{ id: 2, name: 'Mary' },
{ id: 3, name: 'The others' },
{ id: 4, name: 'John' }
];
For the sample array above, the desired result would be:
[
{ id: 3, name: 'The others' },
{ id: 4, name: 'John' },
{ id: 2, name: 'Mary' },
{ id: 1, name: 'Paul' }
]