This article will describe using py-isort package which provides sort of import statement for python.
Table of Contents
1 Install py-isort package
Install py-isort with M-x package-list-packages.
py-isort 0.8 available Use isort to sort the imports in a Python buffer
2 Install isort
Install isort with pip.
$ sudo pip install isort
3 ${HOME}/.emacs
If python-mode is enabled, add py-isort-before-save to before-save-hook.
(add-hook 'python-mode-hook '(lambda() (add-hook 'before-save-hook 'py-isort-before-save)))
4 Execution result
The orders of import are time and random before saving.
The orders of import are random and time after saving.