javascript - Sort the json in the array -
i want sort array, according property such this:
[ {num:5},{num:3},{num:6},{num:9} ]
after sort, want get
[ {num:3},{num:5},{num:6},{num:9} ]
how in javascript?
a sort function (literal) returns 1, -1, 0 ascending, descending , equal respectively.
array.sort(function(a, b) { return a.num - b.num });
Comments
Post a Comment