Sorting divs by multiple conditions
Hi
I had to replace a table list with a div-layout because of a desired hover-effect (additional info appearing when hovering over a row)
before, I was able to sort the table with a jQuery-Plugin (tablesorter). there I had the possibility to sort by multiple columns. for example, first by rating and then by title
Now i have the problem, that I don't get it to sort by multiple conditions.
with 1 row, it looks like this:
- $divs = $('.container');
- var sortData = 'title';
- var sortDir = 'asc';
-
- var orderedDivs = $divs.sort(function(a, b) {
if(sortDir == 'asc')
{
return $(a).find('[data-sort="'+sortData+'"]').text() > $(b).find('[data-sort="'+sortData+'"]').text();
}
else
{
return $(a).find('[data-sort="'+sortData+'"]').text() < $(b).find('[data-sort="'+sortData+'"]').text();
}
});