Repository: timothycrosley/isort (python)

Issue:
Add support for PyCharm style alphabetic sorting (edited from: all upper cases name is sorted top most)
Below is the sorted result using my isort configuration, you could see the both 'BALL' and `RC` is placed at the top most. The name `Action` is placed below 'BALL' and 'RC' is not correct for me:

```python
from pkg import BALL
from pkg import RC
from pkg import Action
from pkg import Bacoo
from pkg import RCNewCode
from pkg import actual
from pkg import rc
from pkg import recorder
```

What I expected is:
```python
from pkg import Action
from pkg import BALL
from pkg import Bacoo
from pkg import RC
from pkg import RCNewCode
from pkg import actual
from pkg import rc
from pkg import recorder
```

That means following the default python string odering:
```python
>>> 'BALL' < 'RC' < 'Action'
False
>>> 'Action' < 'BALL' < 'RC'
True
```

So I wonder whether there is any configuration can make it?


Below is my isort configuration:
```ini
[isort]
line_length = 80
indent = '  '
force_single_line = True
known_first_party=test
```

Pull request:
Fix issue #890
Closes #890 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7ebed58..c5826060 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@ Changelog
 ### 4.3.13 - March 6, 2019 - hot fix release
 - Fixed the inability to accurately determine import section when a mix of conda and virtual environments are used.
 - Fixed some output being printed even when --quiet mode is enabled.
+- Fixed issue #890 interoperability with PyCharm by allowing case sensitive non type grouped sorting
 
 ### 4.3.12 - March 6, 2019 - hot fix release
 - Fix error caused when virtual environment not detected
diff --git a/isort/isort.py b/isort/isort.py
index ff3921bf..22e5d019 100644
--- a/isort/isort.py
+++ b/isort/isort.py
@@ -303,7 +303,8 @@ class SortImports(object):
                 prefix = "B"
             else:
                 prefix = "C"
-        module_name = module_name.lower()
+        if not config['case_sensitive']:
+            module_name = module_name.lower()
         if section_name is None or 'length_sort_' + str(section_name).lower() not in config:
             length_sort = config['length_sort']
         else:
diff --git a/isort/main.py b/isort/main.py
index 299562ed..5da3fb3a 100644
--- a/isort/main.py
+++ b/isort/main.py
@@ -292,6 +292,8 @@ def parse_args(argv=None):
     parser.add_argument('--unsafe', dest='unsafe', action='store_true',
                         help='Tells isort to look for files in standard library directories, etc. '
                              'where it may not be safe to operate in')
+    parser.add_argument('--case-sensitive', dest='case_sensitive', action='store_true',
+                        help='Tells isort to include casing when sorting module names')
     parser.add_argument('files', nargs='*', help='One or more Python source files that need their imports sorted.')
 
     arguments = {key: value for key, value in vars(parser.parse_args(argv)).items() if value}
diff --git a/isort/settings.py b/isort/settings.py
index c796d966..b1075148 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -162,7 +162,8 @@ default = {'force_to_top': [],
            'no_lines_before': [],
            'no_inline_sort': False,
            'ignore_comments': False,
-           'safety_excludes': True}
+           'safety_excludes': True,
+           'case_sensitive': False}
 
 
 @lru_cache()


Test patch:
diff --git a/test_isort.py b/test_isort.py
index fb095fc7..c4b3c241 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -2845,3 +2845,24 @@ def test_unwrap_issue_762():
     test_input = ('from os.\\\n'
                   '    path import (join, split)')
     assert SortImports(file_contents=test_input).output == 'from os.path import join, split\n'
+
+
+def test_ensure_support_for_non_typed_but_cased_alphabetic_sort_issue_890():
+    test_input = ('from pkg import BALL\n'
+                  'from pkg import RC\n'
+                  'from pkg import Action\n'
+                  'from pkg import Bacoo\n'
+                  'from pkg import RCNewCode\n'
+                  'from pkg import actual\n'
+                  'from pkg import rc\n'
+                  'from pkg import recorder\n')
+    expected_output = ('from pkg import Action\n'
+                       'from pkg import BALL\n'
+                       'from pkg import Bacoo\n'
+                       'from pkg import RC\n'
+                       'from pkg import RCNewCode\n'
+                       'from pkg import actual\n'
+                       'from pkg import rc\n'
+                       'from pkg import recorder\n')
+    assert SortImports(file_contents=test_input, case_sensitive=True, order_by_type=False,
+                       force_single_line=True).output == expected_output