Sort array of objects

前端 未结 3 1608
情话喂你
情话喂你 2020-12-12 01:39

I have an array of object literals like this:

var myArr = [];

myArr[0] = {
   \'score\': 4,
   \'name\': \'foo\'
}

myArr[1] = {
   \'score\': 1,
   \'name\         


        
3条回答
  •  轮回少年
    2020-12-12 02:10

    You could have a look at the Array.sort documentation on MDN. Specifically at the documentation about providing a custom compareFunction

提交回复
热议问题