add sortByTotal function
test for sortByTotal
Merge pull request #358 from mattus/sortbytotal

add sortByTotal function