In the case of the content rating site template I wanted to sort the list by rating with the highest rated items rolling to the top:
Here is the expression I used:
format-number(sum(../../../Content_Ratings/Rows/Row[@BPID=@ID]/@Rating)div (@Ratings), ‘###0.0;-###0.0’)
Notice it’s similiar to the rating expression itself. pretty cool.
To do your own you can add directly to your DVWP’s sort/grouping.
Go to your DVWP, select sort and group, remove any prior sort expressions, add a new custom sort expression using the handy x-path editor (hand tweak as necessary for you own needs) and whaaa laaa-