sort imports before saving rewrite

Turned out to be much easier than I thought :)

Fixes #114.