The first if test looks at parameter $1 and does something when that parameter is '-f'. That something is using the same parameter in the 'sort' call which evaluate to:
sort -r -t, -k5 -f > sorted.csv
This will hang as you would have to pipe into the script the file content you wanted sorted and saved in sorted.csv. I suppose when it hangs you could always just type in the csv file contents and finish with CTRL-D :-). The'-f' would do a fold-case sort on my machine.
If what you meant was to pass in a file name:
if [ $# -gt 1 ]
then
if [ $1 = "-f" ]
then
# assume $2 not a control switch for sort but a file name
sort -r -t, -k5 $2 > sorted.csv
fi
fi
if [ $# -eq 1 ]
then
# assume $1 not a control switch for sort but a file name
sort -r -t, -k5 $1
fi