Sort an array by the name of existing property and add a first element into array
Sort array by name and add first element
For e.g. user names - [ {name: 'All'}, {name: 'Aron'}, {name: 'Bob'} ]
1.1.0
Array
{Array} array - The array to sort and add
{String} sortBy - Name of the property from an array by which array will be sorted
{*Any} element - Element which is added into an array
{Array} Returns the new array
sortAndAddFirstElement([{name:'Bob'}, {name:'Aron'}], 'name', {name:'All'});
// => [ {name:'All'}, {name:'Aron'}, {name:'Bob'} ]