extjs - Sort store alphanumerically and case insensitively

user427969 picture user427969 · Mar 30, 2011 · Viewed 16.8k times · Source

I want to sort store (ArrayStore and GroupingStore) alphanumerically and case INSENSITIVELY. I am using singleSort() method but it sorts case sensitively.

For example,

data = ['c', '1', 'A', 'a', 'C']
output = ['1', 'A', 'C', 'a', 'c']
myoutput = ['1', 'a', 'A', 'c', 'C'] or [['1', 'A', 'a', 'C', 'c']    // This is what I want

Any suggestion on how to achieve this?

Answer

Duncan picture Duncan · Feb 29, 2012

I found a much simpler way

using ExtJS 3.3.1, probably works with earlier too.

Simply define the sortType for the field as asUCString, like this:

new Ext.data.JsonStore({ 
   url: 'my.php', 
   fields: [{name:'name', sortType:Ext.data.SortTypes.asUCString}], 
   sortInfo: { field: 'name', direction: 'ASC'} 
});