Order Array By Int, Float, Text Value Javascript

 

var arrayVar = [
{
    name: 'Bobby',
    someValue: 123123
},
{
    name: 'Phillip',
    someValue: 123
}
];

arrayVar = arrayVar.sort((a, b) => {return a.someValue - b.someValue}); // save the sort result
// (a - b) = Ascending sort, (b - a) = Descending sort

console.log(arrayVar);

console.log(hon);

 

Leave a Reply