I'm really struggling to solve this problem. In my Vue.js application, I have an array of objects structured like this:
var food = [{'name':'apples','price':'222.30'},{'name':'bananas','price':'99.30'},{'name':'oranges','price':'199.30'}];
When attempting to sort by price, I've tried the following methods:
return food.sort((a, b) => (a.price > b.price) ? 1 : -1);
AND
return _.orderBy(food, 'price')
Unfortunately, it seems that the sorting interprets $99.30 as higher than $222.30, possibly due to the numeric values within the prices.
Any advice or guidance on how to correctly order from largest to smallest and vice versa would be greatly appreciated!