Improvements for ordering in custom exports

http://manage.dimagi.com/default.asp?86347