Skip to content

Instantly share code, notes, and snippets.

@jdjkelly
Created September 6, 2013 17:06
Show Gist options
  • Save jdjkelly/6466706 to your computer and use it in GitHub Desktop.
Save jdjkelly/6466706 to your computer and use it in GitHub Desktop.
var sortedCoupons = []
var coupons = Object.keys(Store.Menu.Coupons)
coupons.forEach(function(coupon, index, coupons) {
data = Store.Menu.Coupons[coupon]
sortedCoupons.push(data)
})
sortedCoupons.sort(function (a, b) {
if (parseFloat(a.Price) > parseFloat(b.Price))
return 1;
if (parseFloat(a.Price) < parseFloat(b.Price))
return -1;
// a must be equal to b
return 0;
});
sortedCoupons.forEach(function(coupon, index, coupons) {
console.log(coupon.Price, coupon.Name, coupon.Code)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment