I have items that I'm wanting to sort, my items have computed properties on the model that include winning, bidding, closed, and watching
each of these properties is true or false
I want to sort the items so that all the winning items are first, then all the bidding items, then all the watching items, then all the closed items.
How might I achieve this? Do I need to do it all in one sort function or can I specify multiple functions to sort by?
I've tried this for winning, but I'm not sure where to go from here
sortedItems: Ember.computed.sort('filteredItems',function(a,b){
if(a.get('winning') == true && a.get('winning') != b.get('winning')){
return -1;
}
if(a.get('winning') == b.get('winning')){
return 0;
}
if(a.get('winning') == false && a.get('winning') != b.get('winning')){
return 1;
}
}),
Aucun commentaire:
Enregistrer un commentaire