PageRenderTime 36ms CodeModel.GetById 25ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/source/Plug-in/ext/Ext.Store.Sort.js

http://prosporous.googlecode.com/
JavaScript | 17 lines | 17 code | 0 blank | 0 comment | 7 complexity | 39eb59437d2e3ceaa849cf11f1901edf MD5 | raw file
 1Ext.data.Store.prototype.applySort = function() {   
 2    if (this.sortInfo && !this.remoteSort) {   
 3        var s = this.sortInfo, f = s.field;   
 4        var st = this.fields.get(f).sortType;   
 5        var fn = function(r1, r2) {   
 6            var v1 = st(r1.data[f]), v2 = st(r2.data[f]);   
 7            if (typeof(v1) == "string") {   
 8                return v1.localeCompare(v2);   
 9            }   
10            return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);   
11        };   
12        this.data.sort(s.direction, fn);   
13        if(this.snapshot && this.snapshot != this.data) {   
14            this.snapshot.sort(s.direction, fn);   
15        }   
16    }   
17};