Lol... the guy just wants to sort a text file. He doesnt even need the command prompt for that.
*bangs head against the keyboargdsfbyhnisd*
Ok, look, here's a quick QBasic routine that will sort your file for you.
Code:
DIM textline(5000) AS STRING
OPEN "text.txt" FOR INPUT AS #1
loopcounter = -1
DO
loopcounter = loopcounter + 1
LINE INPUT #1, textline(loopcounter)
LOOP UNTIL EOF(1)
CLOSE #1
DO
flag = 0
FOR loopcounter2 = 0 TO loopcounter - 1
IF textline(loopcounter2) > textline(loopcounter2 + 1) THEN
temp$ = textline(loopcounter2)
textline(loopcounter2) = textline(loopcounter2 + 1)
textline(loopcounter2 + 1) = temp$
flag = 1
END IF
NEXT
LOOP UNTIL flag = 0
OPEN "text2.txt" FOR OUTPUT AS #2
FOR lc3 = 0 TO loopcounter
WRITE #2, textline(lc3)
NEXT
CLOSE #2
END
Copy and past that into notepad, and save it as c:\qbasic\sort.bas
Now, go find a copy of Qbasic on the internet - its not hard to find. In fact, you can find a copy at http://webpages.csus.edu/~sac19488/qbasic.htm. Install that to c:\qbasic
Now, put a copy of the text file you want to sort into the directory you installed qbasic in, and rename it to text.txt
Then, just load qbasic. Press alt+F to open the file menu, then O to get the open menu. You should see sort.bas in one of the boxes - that means everythings set right. type sort.bas, and press enter.
Then, press shift+F5. this begins running the program. a few moments later, you'll get "Press any key to continue" appear on a black screen - the program has finished running. press any key, and press alt+f, then x to exit qbasic.
Yeah, i could compile the code, but i figure ill make you do things the hard way.
Note - if the original file contains more than 5000 entries, just change the 5000 on the first line to the number of entries you have. simple, eh?
The routines a basic bubble sort - it does the job, it does it reliably. Just not as quickly as a binary sort, but i cant be bothered to code one atm. Sorted.
Bookmarks