diff --git a/packages/ember-runtime/lib/mixins/sortable.js b/packages/ember-runtime/lib/mixins/sortable.js index 69201d0b682..03292f708fb 100644 --- a/packages/ember-runtime/lib/mixins/sortable.js +++ b/packages/ember-runtime/lib/mixins/sortable.js @@ -18,13 +18,13 @@ import { computed } from "ember-metal/computed"; import { beforeObserver, observer -} from "ember-metal/mixin"; //ES6TODO: should we access these directly from their package or from how thier exposed in ember-metal? +} from "ember-metal/mixin"; //ES6TODO: should we access these directly from their package or from how their exposed in ember-metal? /** `Ember.SortableMixin` provides a standard interface for array proxies to specify a sort order and maintain this sorting when objects are added, removed, or updated without changing the implicit order of their underlying - modelarray: + model array: ```javascript songs = [ @@ -56,8 +56,8 @@ import { songsController.get('firstObject'); // {trackNumber: 4, title: 'Ob-La-Di, Ob-La-Da'} ``` - SortableMixin works by sorting the arrangedContent array, which is the array that - arrayProxy displays. Due to the fact that the underlying 'content' array is not changed, that + `SortableMixin` works by sorting the `arrangedContent` array, which is the array that + `ArrayProxy` displays. Due to the fact that the underlying 'content' array is not changed, that array will not display the sorted list: ```javascript @@ -65,8 +65,8 @@ import { songsController.get('firstObject'); // Returns the sorted content. ``` - Although the sorted content can also be accessed through the arrangedContent property, - it is preferable to use the proxied class and not the arrangedContent array directly. + Although the sorted content can also be accessed through the `arrangedContent` property, + it is preferable to use the proxied class and not the `arrangedContent` array directly. @class SortableMixin @namespace Ember @@ -75,7 +75,7 @@ import { export default Mixin.create(MutableEnumerable, { /** - Specifies which properties dictate the arrangedContent's sort order. + Specifies which properties dictate the `arrangedContent`'s sort order. When specifying multiple properties the sorting will use properties from the `sortProperties` array prioritized from first to last. @@ -85,7 +85,7 @@ export default Mixin.create(MutableEnumerable, { sortProperties: null, /** - Specifies the arrangedContent's sort direction. + Specifies the `arrangedContent`'s sort direction. Sorts the content in ascending order by default. Set to `false` to use descending order. @@ -97,13 +97,14 @@ export default Mixin.create(MutableEnumerable, { /** The function used to compare two values. You can override this if you want to do custom comparisons. Functions must be of the type expected by - Array#sort, i.e. - return 0 if the two parameters are equal, - return a negative value if the first parameter is smaller than the second or - return a positive value otherwise: + Array#sort, i.e., + + * return 0 if the two parameters are equal, + * return a negative value if the first parameter is smaller than the second or + * return a positive value otherwise: ```javascript - function(x,y) { // These are assumed to be integers + function(x, y) { // These are assumed to be integers if (x === y) return 0; return x < y ? -1 : 1; @@ -154,12 +155,11 @@ export default Mixin.create(MutableEnumerable, { isSorted: computed.notEmpty('sortProperties'), /** - Overrides the default arrangedContent from arrayProxy in order to sort by sortFunction. - Also sets up observers for each sortProperty on each item in the content Array. + Overrides the default `arrangedContent` from `ArrayProxy` in order to sort by `sortFunction`. + Also sets up observers for each `sortProperty` on each item in the content Array. @property arrangedContent */ - arrangedContent: computed('content', 'sortProperties.@each', function(key, value) { var content = get(this, 'content'); var isSorted = get(this, 'isSorted');