|I'm assuming you want the sort in the result of the DIR command, and THEN add that to the existing filelist.txt|
If you want the filelist.txt to be sorted AFTER you add the result from the curent DIR command, you need to do something else.
You can call :
<script>.cmd "C:\documents and settings"
if -%1==- goto :EOF
dir %varpath% /a/b/-p/o:gen | sort >> "C:\Documents and Settings\%username%\Desktop\filelist.txt"