opened
marcofavorito
username_0
`isort` (version `5.4.2`) seems not able to correctly sort imports such as:
```python
from x import AA, CC, B
```

Where I expected:
```python
from x import AA, B, CC
```

`isort` seems to care about the length (sorts in decreasing length order), but looks wrong to me; it should first look to the actual characters. In this case, `B` must be before `CC` and after `AA`).

Am I missing something very silly?
isort not able to sort very simple example
issue
created
timothycrosley
username_1
Hi @username_0,

This is intentional! And, usually, helpful I believe. isort, by default, orders by implied type and then alphabetically. You can turn this off by turning off order_by_type: https://pycqa.github.io/isort/docs/configuration/options/#order-by-type.

In real-life usage the usefulness becomes more obvious, I believe:

As an example, here is a common set of imports from the `typing` module imported by isort
```
from typing import TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Tuple, cast
```

So in your example:

```
from x import AA, CC, B
```

The implied type of AA and CC are CONSTANT because they are more than one letter and all capital.
The implied type of B is class, because it starts with a capital. Admittedly, beside code bases that don't follow common Pep8 naming guidelines, single letter characters are the one area of ambiguity, where it could really be a valid class or constant.
You can also tell isort to view B as a constant as well by adding it to a list of `constants` in your settings.

I hope this is helpful!

~Timothy
comment
created
marcofavorito
username_0
Hi @username_1 ,

thank you for your explanation, that is very helpful :-)

`flake8-import-order` seems to don't care about the type, just alphanumerical order. Is that a known issue as well?
(There are other discrepancies regarding the order of categories of import statements, but that's a bit out of the scope I guess).
comment
created
timothycrosley
username_1
There are many incompatibilities between flake8-import-order and isort, simply because they were built completely independently of each-other. isort can generally be configured to be compatible with flake8-import-order simply because it is so configurable, but it's not a major aim of the project currently, simply because https://github.com/gforcada/flake8-isort exists and ensures full compatibility with isort.  There may be future room for deeper collaboration between the three projects.
comment
created
marcofavorito
username_0
Fantastic, will check out `flake8-isort`! Please keep pushing with this project, it's awesome :smile:
comment
closed
timothycrosley
username_1
issue