Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays Angularjs-数组中对象的orderby属性_Arrays_Angularjs_Javascript Objects_Angularjs Filter - Fatal编程技术网

Arrays Angularjs-数组中对象的orderby属性

Arrays Angularjs-数组中对象的orderby属性,arrays,angularjs,javascript-objects,angularjs-filter,Arrays,Angularjs,Javascript Objects,Angularjs Filter,我有一个对象数组matchedProfiles,我正试图按属性值对这些对象进行排序 matched profiles = [ { common: Array[1], match: 8.333333333333329, score1: Array[1], score2: Array[1], user1ID: "1116145178404907", user2ID: "1710007182568600" }, { common: Array[1], match: 25, score1: Ar

我有一个对象数组
matchedProfiles
,我正试图按属性值对这些对象进行排序

matched profiles = [ 

{
common: Array[1],
match: 8.333333333333329,
score1: Array[1],
score2: Array[1],
user1ID: "1116145178404907",
user2ID: "1710007182568600"
}, 

{
common: Array[1],
match: 25,
score1: Array[1],
score2: Array[1],
user1ID: "170401213316838",
user2ID: "1710007182568600"
}

]
我试着订购这个阵列

var sortedMP = $filter('orderBy')(matchedProfiles, match);
但是控制台日志中有个错误

Uncaught ReferenceError: match is not defined
像这样试试

var sortedMP = $filter('orderBy')(matchedProfiles, 'match');

根据文档,您可以将表达式作为字符串传递
'match'

var sortedMP = $filter('orderBy')(matchedProfiles, 'match');
或功能

var sortedMP = $filter('orderBy')(matchedProfiles, function(profile) {
    return profile.match;
});