Is there a way to provide a sort order to an mdfind query?

I used the following shell function to provide the sort:

function sort_file()
{
    TMPFILE=`mktemp /tmp/sortable.XXXXXX` || exit 1
    export MDLS="mdls -raw -name kMDItemAlbum -name kMDItemAudioTrackNumber"
    export TR="tr \"\0\" \"\;\""
    awk '{system( "$MDLS \"" $0 "\" | $TR" ); print "\;"$0; }' $1 > $TMPFILE
    sort -t\; -k 2n -k 1f $TMPFILE | awk -F";" '{ print $3; }' > $1
}

META NOTE: I would have put this in a comment in the above answer, but couldn't get it to format correctly.