Sort dependencies when --save'ing.

Uses sorted-object package to abstract away code shared by shrinkwrap and
install.

Supercedes #4390.