need help with a script!

i need to write a script which shows all the users and there processes they are running. i have tried using the ls and ps commands together but cannot get any sort of results. the output should look like this:

Lee Ballancore
PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim
2495 pts/7 00:00:00 vim
8368 pts/0 00:00:00 vim
9544 pts/2 00:00:00 ps

Alistairr Rutherford
PID TTY TIME CMD
8368 pts/0 00:00:00 vim
9544 pts/2 00:00:00 ps

For system V unix:

#!/bin/sh
oldusername=""
ps -eo user,pid,tty,time,comm | tail +2 | sort | while read line
do
  username=`echo $line | awk '{ print $1 }'`
  if [ "$username" != "$oldusername" ]
  then
    grep "${username}:" /etc/passwd | cut -d ':' -f 5
    oldusername=$username
  fi
  echo $line | awk '{ print $2 $3 $4 $5 }'
done

any idea how i can use that code without the use of sed and awk commands? would grep be another alternative, wat would it look like?

Why, is this homework?

Regards