How can I make this sort faster and better?
function OrderBy(a,b) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
SortBy = function($th) {
var $tbody = $th.closest('tbody');
var $table = $tbody.parent();
$tbody.detach();
$('#Processing').show('fast',function () {
var column = $th.index();
var rows = $tbody.find('tr').get();
rows.sort(function(rowA,rowB) {
var keyA = $(rowA).children('td').eq(column).text();
var keyB = $(rowB).children('td').eq(column).text();
return OrderBy(keyA,keyB);
});
$.each(rows, function(index,row) {
$tbody.append(row);
});
$table.append($tbody);
});
};