How to open the last modified file in a directory?

The best solution I found so far is using the following in a shell script:

for f in `ls -t /path/to/directory/*`; do
  vi $f
  break
done