X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..HEAD:/src/util/Sorter.js diff --git a/src/util/Sorter.js b/src/util/Sorter.js index aaa0f4df..c233df42 100644 --- a/src/util/Sorter.js +++ b/src/util/Sorter.js @@ -13,93 +13,91 @@ If you are unsure which license is appropriate for your use, please contact the */ /** - * @class Ext.util.Sorter - * @extends Object - -Represents a single sorter that can be applied to a Store. The sorter is used -to compare two values against each other for the purpose of ordering them. Ordering -is achieved by specifying either: -- {@link #property A sorting property} -- {@link #sorterFn A sorting function} - -As a contrived example, we can specify a custom sorter that sorts by rank: - - Ext.define('Person', { - extend: 'Ext.data.Model', - fields: ['name', 'rank'] - }); - - Ext.create('Ext.data.Store', { - model: 'Person', - proxy: 'memory', - sorters: [{ - sorterFn: function(o1, o2){ - var getRank = function(o){ - var name = o.get('rank'); - if (name === 'first') { - return 1; - } else if (name === 'second') { - return 2; - } else { - return 3; - } - }, - rank1 = getRank(o1), - rank2 = getRank(o2); - - if (rank1 === rank2) { - return 0; - } - - return rank1 < rank2 ? -1 : 1; - } - }], - data: [{ - name: 'Person1', - rank: 'second' - }, { - name: 'Person2', - rank: 'third' - }, { - name: 'Person3', - rank: 'first' - }] - }); - - * @markdown + * Represents a single sorter that can be applied to a Store. The sorter is used + * to compare two values against each other for the purpose of ordering them. Ordering + * is achieved by specifying either: + * + * - {@link #property A sorting property} + * - {@link #sorterFn A sorting function} + * + * As a contrived example, we can specify a custom sorter that sorts by rank: + * + * Ext.define('Person', { + * extend: 'Ext.data.Model', + * fields: ['name', 'rank'] + * }); + * + * Ext.create('Ext.data.Store', { + * model: 'Person', + * proxy: 'memory', + * sorters: [{ + * sorterFn: function(o1, o2){ + * var getRank = function(o){ + * var name = o.get('rank'); + * if (name === 'first') { + * return 1; + * } else if (name === 'second') { + * return 2; + * } else { + * return 3; + * } + * }, + * rank1 = getRank(o1), + * rank2 = getRank(o2); + * + * if (rank1 === rank2) { + * return 0; + * } + * + * return rank1 < rank2 ? -1 : 1; + * } + * }], + * data: [{ + * name: 'Person1', + * rank: 'second' + * }, { + * name: 'Person2', + * rank: 'third' + * }, { + * name: 'Person3', + * rank: 'first' + * }] + * }); */ Ext.define('Ext.util.Sorter', { /** - * @cfg {String} property The property to sort by. Required unless {@link #sorterFn} is provided. - * The property is extracted from the object directly and compared for sorting using the built in - * comparison operators. + * @cfg {String} property + * The property to sort by. Required unless {@link #sorterFn} is provided. The property is extracted from the object + * directly and compared for sorting using the built in comparison operators. */ /** - * @cfg {Function} sorterFn A specific sorter function to execute. Can be passed instead of {@link #property}. - * This sorter function allows for any kind of custom/complex comparisons. - * The sorterFn receives two arguments, the objects being compared. The function should return: - *