Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#15534 closed enhancement (fixed)

enhance SimpleQueryEngine to take sort function (vs. just field)

Reported by: jameyg Owned by: Kris Zyp
Priority: undecided Milestone: 1.8
Component: Data Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:


Store.query() should allow options.sort to be either an attribute or a sort function.

Example use case here is a collative sort where the Store contains a key into an NLS bundle (or any case where the store doesn't have the actual value to sort on).


store.query(null, {
   sort: [{
       sorter: function(a, b) {
          return bundle[a['field']].localeCompare(bundle[b['field']]);
       descending: true

NOTE that this example also implies a change to make the sorting and asc|desc "flipping" separate concerns...e.g.:

array.sort(function(a,b) {
   return sorter(a,b) * (descending ? -1 : 1);

Possible alternative is to make SQE easier to patch.

Change History (3)

comment:1 Changed 9 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [29085]:

Properly handle nulls in sorting and allow sorting functions, fixes #15534, fixes #15515 !strict

comment:3 Changed 9 years ago by bill

Milestone: tbd1.8

comment:4 Changed 9 years ago by jameyg

i may be misreading the patch, but i'm not sure this is an effective solution. For example, how would this work w/ dgrid (there's no apparent standard way to specify the column being sorted on, or the sort direction). Admittedly what I described in the request suffers the same type of problem - perhaps what I really want is to set a config on the Store/SQE itself:

store.set('sorters', {'field1':function(a,b,desc) {...}});

Note: See TracTickets for help on using tickets.