JSFiddle - React, Tailwind, and code Playground
JavaScript
var arr = [{
"id": 1,
"name": "Skateboard",
"price": 1299,
"currency": "SEK",
"thumbnail": "/static/img/products/1-t.jpg"
},
{
"id": 4,
"name": "A trip to the sun with Erik",
"price": 29000,
"currency": "SEK",
"thumbnail": "/static/img/products/4-t.jpg"
},
{
"id": 1,
"name": "Skateboard",
"price": 1299,
"currency": "SEK",
"thumbnail": "/static/img/products/1-t.jpg"
},
{
"id": 4,
"name": "A trip to the sun with Erik",
"price": 29100,
"currency": "SEK",
"thumbnail": "/static/img/products/4-t.jpg"
}, {
"id": 4,
"name": "A trip to the sun with Erik",
"price": 29000,
"currency": "SEK",
"thumbnail": "/static/img/products/4-t.jpg"
}, ]
alert(JSON.stringify(arr.sort(function(a,b) { return parseFloat(a.price) - parseFloat(b.price) } )));