1. // 重载 Ext.data.Store.prototype.applySort 函数以修复 DataStore 对汉字排序异常的问题 
2.    
3. // var _applySort = Ext.data.Store.prototype.applySort;         
4.    
5. //如有需要,保存原 applySort 函数的引用 
6.    
7. function(){        //重载 applySort 
8.    
9. if(this.sortInfo && !this.remoteSort){    //sortInfo对象存在并且不是远程排序
10.    
11. var s = this.sortInfo, f = s.field;    
12.    
13. var st = this.fields.get(f).sortType;    
14.    
15. var fn = function(r1, r2){    
16.    
17. var
18.    
19. // 添加:修复汉字排序异常的Bug 
20.    
21. if(typeof(v1) == "string"){ //若为字符串类型, 
22. //则用 localeCompare 比较汉字字符串, Firefox 与 IE 均支持
23. return
24.                                                  }    
25.    
26. //若不是字符串类型
27. return
28.    
29.                                         };    
30.    
31. this.data.sort(s.direction, fn);    
32.    
33. if(this.snapshot && this.snapshot != this.data){   //数据快照 
34.    
35. this.snapshot.sort(s.direction, fn);    
36.    
37.                                         }    
38.    
39.                                 }    
40.    
41.                         };