我正在使用ember js。
ac = [
{"name" : "Arasad", "price": 350.50},
{"name" : "Brasad", "price": 350.50},
{"name" : "Crasad", "price": 350.50},
{"name" : "Corasad", "price": 350.50},
{"name" : "Cddasad", "price": 350.50},
{"name" : "Dcprasad", "price": 350.50},
{"name" : "Ewasadrrrrrrr", "price": 350.50},
{"name" : "Wrasad", "price": 350.50},
{"name" : "Axrasad", "price": 350.50},
{"name" : "Sxasad", "price": 350.50},
{"name" : "Weasad", "price": 350.50},
{"name" : "Saasad", "price": 350.50},
{"name" : "prasad", "price": 350.50}
]
abc = Ember.ArrayController.create({
model: ac.sortBy('name'),
sortProperties: ['price'],
sortAscending: false
})
排序后,我打印以下元素。 abc.toArray()[0] 对象{名称:“Dcprasad”,价格:350.5, ember_meta :Meta}
有什么建议,如何对ember js中的对象数组进行排序?
实际上我的真正要求是按价格和名称排序。 最高价格首先,如果价格相等,则按名称递增排序。
谢谢, 普拉萨德。
答案 0 :(得分:1)
这篇文章应该会有所帮助:Ember - sort array by multiple properties in multiple directions
另外,这里有一个jsbin详细说明:http://emberjs.jsbin.com/cevivahiso/14/edit