Begining Shell scripter

I am trying to write for my class project a shell script, using bourne shell, that will take one command, either -l or -w. If -l is entered then the script should output the names of all the files in my working directory sorted in increasing order of the number of lines in the file. If -w is input then the same ill be done except that it will be sorted in increasing order by the number of words in the files. I know the solu'n will use the command ls and a pipeline to sort. but I don't know how to list the files or sort the files by the number of words or lines that they have. so far I have
#!/bin/sh

print=`ls | sort`
echo $print

this is not exactly correct but if I knew how to sort the files according to the number of lines each had, then I could rearrange this code to adapt.
Any help would be really appreciated. The project is not worth much at all but I am curious as how to sort this way. Thank you.

do a 'man wc' for more information on the word count command.

#!/bin/bash
if [ $# -ne 1 ]
then
echo "usage: `basename $0` <-l|-w>"
exit 1
fi

case "$1" in
-l)
echo lines/filename
wc -l * | sort | grep -v ` basename $0` | grep -v ' total'
;;
-w)
echo words/filename
wc -w * | sort | grep -v ` basename $0` | grep -v ' total'
;;
*)
echo "usage: $0 <-l|-w>"
exit 1
;;
esac