Model Data Sorting/Ordering


I have a question about re-ordering the model data. So we have product data returned from our API that is in a specific order. But there are instances in our application where only some products are loaded first (for instance, the shopping cart where it only loads the products in the cart).

If that happens, then the ordering of the model is off since it’s in order of what was loaded first.

I do have a temporary fix where I re-sort the data before displaying it within a component, but it seems redundant (as the API call to retrieve all the products are already in proper order) and also adds additional overhead to the load time.

Is there a simpler way of doing this or am I stuck having to re-sort it retroactively?

To note, I’m using Ember 2.5 and strangely it never happened on Ember 1.13.


Nevermind, I think we will go with a simpler solution of just having a model attribute for sort order which we can just do a sortBy on.


Don’t rely on the data coming straight from the store being in any specific order. Just sort what you have client-side, it really shouldn’t be a big performance hit at all.


How would you reconcile that with pagination?


He is talking specifically about entities that are already in the store (in which case apply some basic client-side pagination):

If you want to paginate server-side, simply order and paginate server-side, and display the results from this call (in which case you would never have to worry about out-of-order entities since you are displaying the results from the ordered and paginated call).