sort multiple sort-only elements correctly

Ready to go!

fixes: http://manage.dimagi.com/default.asp?77485