Opened 15 years ago

Closed 15 years ago

#2209 closed defect (invalid)

FilteringTable sorting is deadly inefficient

Reported by: Jonathan Bond-Caron Owned by: Tom Trenka
Priority: high Milestone: 0.9
Component: Widgets Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:


The createSorter method introduces a highly inefficient comparison function:

i.e. it returns:

return function(rowA, rowB){

var idx=0; while(idx < sortFunctions.length){

var ret = sortFunctions[idx++](rowA, rowB); if(ret != 0) return ret;

} if we got here then we must be equal. return 0;

}; function

I don't think the developper realized this function would get called intensively!

i.e. for 300 records, there are 3725 calls made by Array.sort It should at the bare minimum return:

return function(rowA, rowB){

if(dojo.html.hasAttribute(rowA,"emptyRow")){ return 1; } if(dojo.html.hasAttribute(rowB,"emptyRow")){ return -1; }

var a =, field); var b =, field); var ret = 0; if(a > b) ret = 1; if(a < b) ret = -1; return dir * ret;


Even then, it should really be comparing only the row values directly, not going through the data store every time!

Change History (2)

comment:1 Changed 15 years ago by Tom Trenka

Milestone: 0.5
Owner: changed from bill to Tom Trenka
Priority: highnormal
severity: criticalnormal

comment:2 Changed 15 years ago by Tom Trenka

Resolution: invalid
Status: newclosed

Actually, I did realize that, and actually...there happens to be a reason that the sorting function goes through the underlying store and not the row data; what you see in the row is not necessarily what the table is sorting on. For instance, if the column in question is representing a Date object, you have two options: take the value from the row, cast it to a Date, and use that for sorting...or you can grab the value that is already cast as a Date in the underlying store, and use that instead.

Thanks for the point out, but I'm going to close this as invalid. Optimizations are not bugs.

Note: See TracTickets for help on using tickets.