I am having a heck of a time figuring this one out. I have an array of objects in my vuejs app like so:
var food= [{'name':'apples','price':'222.30'},{'name':'bananas','price':'99.30'},{'name':'oranges','price':'199.30'}];
When I try to sort by price, I am trying both
return food.sort((a, b) => (a.price> b.price) ? 1 : -1);
AND
return _.orderBy(food, 'price')
However it seems this interprets the price $99.30 as higher than $222.30 - I am assuming because 9 is higher than 2?
Any help would be appreciated! I am also wondering if there is a way to order largest to smallest and vice versa.