Improvements for ordering in custom exports

http://manage.dimagi.com/default.asp?86347#695228
Probably want to remove this once you're done debugging.