I have a number of pages with sortable columns, the code is like
var invert = $('...').val();
var column = $('...').val();
$list.children().detach().sort(function (a,b) {
var aa = $(a).find('.'+column).html().trim();
var bb = $(b).find('.'+column).html().trim();
// conversions cut off
return invert ? aa-bb : bb-aa;
}).appendTo($list);
where column is a class of the column to sort. I'd like to make it one callback function instead of repeating the code
function column_sorter(a, b) {
var aa = $(a).find('.'+column).html().trim();
// ....
}
$list.children().detach().sort(column_sorter).appendTo($list);
but column is inaccessible here (and invert probably - too). Is there any possibility to utilize the function here?