Improvements for ordering in custom exports

http://manage.dimagi.com/default.asp?86347#695228
These commented lines should be removed now that the code has been moved elsewhere.