github.com/emate/nomad@v0.8.2-wo-binpacking/ui/app/components/gutter-menu.js (about) 1 import { inject as service } from '@ember/service'; 2 import Component from '@ember/component'; 3 import { computed } from '@ember/object'; 4 5 export default Component.extend({ 6 system: service(), 7 8 sortedNamespaces: computed('system.namespaces.@each.name', function() { 9 const namespaces = this.get('system.namespaces').toArray() || []; 10 11 return namespaces.sort((a, b) => { 12 const aName = a.get('name'); 13 const bName = b.get('name'); 14 15 // Make sure the default namespace is always first in the list 16 if (aName === 'default') { 17 return -1; 18 } 19 if (bName === 'default') { 20 return 1; 21 } 22 23 if (aName < bName) { 24 return -1; 25 } 26 if (aName > bName) { 27 return 1; 28 } 29 30 return 0; 31 }); 32 }), 33 34 onNamespaceChange() {}, 35 });