Skip to content

Instantly share code, notes, and snippets.

@miguelcobain
Last active January 30, 2017 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save miguelcobain/19ff8c56f1c13512bdc8 to your computer and use it in GitHub Desktop.
Save miguelcobain/19ff8c56f1c13512bdc8 to your computer and use it in GitHub Desktop.
sort computed
import Ember from 'ember';
const { computed } = Ember;
export default Ember.Controller.extend({
appName:'Ember Twiddle',
entries: [
{
id: 1,
name: 'Eric'
},
{
id: 2,
name: 'Wilson'
},
{
id: 3,
name: 'Miguel'
}
],
entriesSorting: ['id:desc'],
sortedEntries: computed.sort('entries', 'entriesSorting')
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
<ul>
{{#each sortedEntries as |e|}}
<li>{{e.id}} - {{e.name}}</li>
{{/each}}
</ul>
<br>
<br>
{
"version": "0.4.17",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment