I have an array:
var arr = [
{price: 5, amount: 100},
{price: 3, amount: 50},
{price: 10, amount: 20},
{price: 3, amount: 75},
{price: 7, amount: 15},
{price: 3, amount: 65},
{price: 2, amount: 34}
]
I want to remove the duplicates which has the same price, and only keep the last duplicate one then sort the array based on price from highest to lowest. Here is the result I want:
var result = [
{price: 10, amount: 20},
{price : 7, amount: 15},
{price: 5, amount: 100},
{price: 3, amount: 65},
{price: 2, amount: 34}
]