Skip to content

Instantly share code, notes, and snippets.

@onechiporenko
Last active April 22, 2016 21:05
Show Gist options
  • Save onechiporenko/83ed55ef7169c8dacefe to your computer and use it in GitHub Desktop.
Save onechiporenko/83ed55ef7169c8dacefe to your computer and use it in GitHub Desktop.
computed.sort issue
import Ember from 'ember';
export default Ember.Controller.extend({
version: Ember.VERSION,
sortBy11: [],
sortBy12: ['a'],
c1: [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 5}, {a: 6}, {a: 7}, {a: 8}, {a: 9}, {a: 10}],
small1: Ember.computed.sort('c1', 'sortBy11'),
small2: Ember.computed.sort('c1', 'sortBy12'),
sortBy21: [],
sortBy22: ['a'],
c2: [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 5}, {a: 6}, {a: 7}, {a: 8}, {a: 9}, {a: 10}, {a: 11}, {a: 12}, {a: 13}, {a: 14}, {a: 15}, {a: 16}, {a: 17}, {a: 18}, {a: 19}, {a: 20}],
big1: Ember.computed.sort('c2', 'sortBy21'),
big2: Ember.computed.sort('c2', 'sortBy22')
});
<p><strong>Ember {{version}}</strong></p>
<table>
<tr>
<td>
Original "small" data:
<ul>
{{#each c1 as |item|}}
<li>{{item.a}}</li>
{{/each}}
</ul>
</td>
<td>
Sorted with <strong>empty</strong> `sort properties`:
<ul>
{{#each small1 as |item|}}
<li>{{item.a}}</li>
{{/each}}
</ul>
</td>
<td>
Sorted with <strong>filled</strong> `sort properties`:
<ul>
{{#each small2 as |item|}}
<li>{{item.a}}</li>
{{/each}}
</ul>
</td>
</tr>
<tr>
<td>
Original "big" data:
<ul>
{{#each c2 as |item|}}
<li>{{item.a}}</li>
{{/each}}
</ul>
</td>
<td>
Sorted with <strong>empty</strong> `sort properties`:
<ul>
{{#each big1 as |item|}}
<li>{{item.a}}</li>
{{/each}}
</ul>
</td>
<td>
Sorted with <strong>filled</strong> `sort properties`:
<ul>
{{#each big2 as |item|}}
<li>{{item.a}}</li>
{{/each}}
</ul>
</td>
</tr>
</table>
{{outlet}}
{
"version": "0.6.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "release",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "release"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment