code: def hacking_import_alphabetical(logical_line, blank_before, previous_logical,
                                  indent_level, previous_indent_level):
      r
      # handle import x
      # use .lower since capitalization shouldn't dictate order
      if blank_before < 1 and indent_level == previous_indent_level:
          split_line = core.import_normalize(logical_line.
                                             strip()).lower().split()
          split_previous = core.import_normalize(previous_logical.
                                                 strip()).lower().split()
          length = [2, 4]
          if (len(split_line) in length and len(split_previous) in length and
                  split_line[0] == "import" and split_previous[0] == "import"):
              if split_line[1] < split_previous[1]:
                  yield (0, "H306: imports not in alphabetical order (%s, %s)"
                         % (split_previous[1], split_line[1]))
docs: r"""Check for imports in alphabetical order.
  
      OpenStack HACKING guide recommendation for imports:
      imports in human alphabetical order
  
      Okay: import os\nimport sys\n\nimport nova\nfrom nova import test
      Okay: import os\nimport sys
      H306: import sys\nimport os
      Okay: import sys\n\n# foo\nimport six