I have this fiddle which was based on the results from this question. I am trying to extend this further so that I can add a secondary sort so that if total price is the same it then looks to the commission column and whoever has the highest commission will go on top where the total sale price is equal. Is this possible? I am also having trouble with getting the commision column to be 2 decimal places. I have tried doing
var commish = '.text((val.price / 3) + (val.sales*5))';
and in the results section.
$("<td></td>");commish.toFixed(2).appendTo($tr);
But this has not worked.
Calculate the commission and store in the objects, so that you can use it both in the sorting and the display:
To sort on the commission secondary, check if the price is equal, and if it is return the comparison for the commission:
When you have the commission in the object, it’s easy to format it for display:
Demo: http://jsfiddle.net/Guffa/VNSam/9/