diff --git a/src/commands/import_symbol.py b/src/commands/import_symbol.py index 84231f9..581b74d 100644 --- a/src/commands/import_symbol.py +++ b/src/commands/import_symbol.py @@ -247,7 +247,15 @@ def run(self): ) self.import_statements = dict( - sorted(self.import_statements.items(), key=lambda k: k[0]) + sorted( + self.import_statements.items(), + # put imports first, then sort by depth, then by name + key=lambda k: ( + not k[0].startswith("import "), + k[0].count("."), + k[0], + ), + ) ) self.view.erase_status(PyRockConstants.PACKAGE_NAME)