My aim is to arrange objects based on a specific property (price).
var arr = [{
name: 'Apple',
price: '1.03'
},
{
name: 'Cherry',
price: '0.33'
},
{
name: 'Mango',
price: '0.53'
}
]
Using lodash to sort the array by their prices:
arr = _.sortBy(arr, 'price' ).reverse();
After sorting, arr[0]
should be Apple since it has the highest price, but that's not the case.
What could possibly be the issue?