jeudi 18 juin 2015

Emberjs advanced sort hasMany association as a computed property

I have asked a variant of this question here. But basically I need to create a computed property that operated on a hasMany association. I need to do sorting similar to the javascript sort function; where I can do something like

files = ["File 5", "File 1", "File 3", "File 2"];
files.sort(function(a,b){
  return parseInt(b.split(' ').pop()) - parseInt(a.split(' ').pop())
});

result:

["File 5", "File 3", "File 2", "File 1"]

Here is my jsbin: http://ift.tt/1Gkk8P8

Any help would be greatly appreciated.

Note: My jsbin presently is not working correctly (for reasons other then this question). I have posted a question about that here. I just did not want to hold up an answer to this question.

Aucun commentaire:

Enregistrer un commentaire