Improvements for ordering in custom exports - code update after QA

I fixed:
http://manage.dimagi.com/default.asp?137670
http://manage.dimagi.com/default.asp?137681
but I can't reproduce this one, I can locally download or bulk reports:
http://manage.dimagi.com/default.asp?137682