This question already has an answer here:
I have an array of objects
var winners_tie = [
{name: 'A', value: 111},
{name: 'B', value: 333},
{name: 'C', value: 222},
]
I wanna sort it in ascending order of value
This question already has an answer here: I have an array of objects
I wanna sort it in ascending order of |
|||
marked as duplicate by laggingreflex, Sterling Archer, thefourtheye, karthik, Micha Apr 15 '14 at 5:56This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. |
|||
|
Since your values are just numbers, you can return their differences from the comparator function
Output
Note: JavaScript's sort is not guaranteed to be stable. |
|||
|
Try this one:
For Demo : Js Fiddle |
||||
|
For arrays:
|
|||
|