sort multiple sort-only elements correctly

fixes: http://manage.dimagi.com/default.asp?77485