jeudi 25 décembre 2014

EmberJS - Sorting data prior to showing

I have a set of json data I get from server, what I need is to sort them before I show to screen.


Data Example:



{
"statuses": [
{
"id": 1,
"title":"Post title 1",
"date":"2014-12-20T11:30:48+0000",
"sticky":true,
"comments":[]
},
{
"id": 2,
"title":"Post title 2",
"date":"2014-12-25T11:30:48+0000",
"sticky":false,
"comments":[]
},
{
"id": 3,
"title":"Post title 3",
"date":"2014-12-15T11:30:48+0000",
"sticky":true,
"comments":[]
},
{
"id": 4,
"title":"Post title 4",
"date":"2014-12-10T11:30:48+0000",
"sticky":false,
"comments":[]
}
]
}


I need to



  1. Show sticky statuses first sticky: true sort by date descending.

  2. After then show normal statuses sticky: false sort by date descending


So far I was just able to list them in given data order. You can see the example here http://ift.tt/1CGz9xS





Aucun commentaire:

Enregistrer un commentaire