Reversing file order using SED

Im trying to develop a shell script that will change the content order of the file.

For example I have a file that says
a
b
c
d

I want to change this to be
d
c
b
a

Im trying to use sed to this by reading the file and then inserting each line at the top

#!/usr/bin/ksh

PATCHFILE=patch_order
REVERSE=reverse_
REVERSEPATCHFILE=$REVERSE$PATCHFILE
TMP=.TMP

rm $REVERSEPATCHFILE$TMP

echo got here
while read PATCHNAME; do

sed -e "1i\\\\
$PATCHNAME"  >$REVERSEPATCHFILE$TMP

#mv $REVERSEPATCHFILE$TMP $REVERSEPATCHFILE

done <$PATCHFILE

The problem is it just puts the lines in exactly the same order. Am i missing something?

why use the wrong utility to do the job?

man sort.

and if you teacher says not useing sed is incorrect. tell him he must be one of those people who like to walk to work instead of drive to work.

Optimus_P, this doesn't look like homework to me. Reversing a list of patches may be necessary to back them all out correctly. I do agree that "sed" is not a great choice. But we need more than just "sort". We can't assume that the data is currently sorted.

MBGPS, it looks like you completely overwrite the file on each iteration. If you don't have the "rev" command, try this:
nl -ba input | sort -nr | cut -f2- > output

Like cat, there is command named 'tac' which works same as that cat, except it reverse the order.
ur script can be like:

tac f1 > f1.tmp
mv f1.tmp f1