Number Sorting

var items = [
{ name: 'Edward', value: 21 },
{ name: 'Sharpe', value: 37 },
{ name: 'And', value: 45 },
{ name: 'The', value: -12 },
{ name: 'Magnetic', value: 13 },
{ name: 'Zeros', value: 37 }
];

var that = items.sort(function(a, b) {
var textA = a.value;
var textB = b.value;
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
});

console.log(that);

Output:

Array will be sorted from -12 to 45 in Ascending order, regardless of other obeject property

Want a Fast Server Like Mine?

GET VULTR!