Skip to content

Instantly share code, notes, and snippets.

@Riduidel
Created December 30, 2009 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Riduidel/265975 to your computer and use it in GitHub Desktop.
Save Riduidel/265975 to your computer and use it in GitHub Desktop.
function generateSorter(tableId, columnIndex, order) {
return function(firstRow, secondRow) {
var firstText = getTextForCell(firstRow, columnIndex);
var secondText = getTextForCell(secondRow, columnIndex);
var returned = (firstTextsecondText ? 1 : 0));
if(returned==0) {
// getSortOrder returns a 1-based sort index for this column
var columnSortIndex = getSortOrder(tableId, columnIndex);
if(columnSortIndex!="") {
columnSortIndex = columnSortIndex-1;
var sorting = currentSorting\[tableId\];
// increment the column sort
if(sorting.length>++columnSortIndex) {
returned = generateSorter(tableId, sorting\[columnSortIndex\], 1)(firstRow, secondRow);
}
}
}
return order*returned;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment