我正在使用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:元}
有什么建议,如何在ember js中对对象数组进行排序?
实际上,我真正的要求是按价格和名称排序。
最高价格优先,如果价格相等,则按名称升序排列。
谢谢,
普拉萨德
最佳答案
这篇文章应该会有所帮助:Ember - sort array by multiple properties in multiple directions
另外,这是一个详细介绍它的jsbin:http://emberjs.jsbin.com/cevivahiso/14/edit
关于javascript - Ember 分选不起作用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28535151/