I'm trying to sort objects based by its property (price)
var arr = [{
name: 'Apple',
price: '1.03'
},
{
name: 'Cherry',
price: '0.33'
},
{
name: 'Mango',
price: '0.53'
}
]
Now i use lodash to sort it by its price:
arr = _.sortBy(arr, 'price' ).reverse();
Now arr[0]
should be Apple, since it's price is highest, but it's not.
What could be wrong?