Indentation-based Sort Given an ordered list of same-case letter strings (a-z XOR A-Z) where each string is preceded by 0 or more space ( ) characters, output the same list but with the strings sorted at each level of indentation. Indentation depths under different parents count as distinct lists for sorting purposes.

Example

If your input is:

bdellium
  fox
  hound
  alien
aisle
  wasabi
    elf
    alien
  horseradish
    xeno
irk
wren
tsunami
djinn
      zebra


your output should be

aisle
  horseradish
    xeno
  wasabi
    alien
    elf
bdellium
  alien
  fox
  hound
djinn
      zebra
irk
tsunami
wren


If you like, think of it like a directory listing, and you need to sort the names within each directory.

Minutiae


An item may be indented by any number of spaces. If it is indented by the same number of spaces as the previous item it belongs in the same sort hierarchy as the previous item. If it is indented by more spaces it is the start of a new sub-hierarchy.
If a line is indented by fewer spaces than the line above it, it links up to the closest sub group above it with the same # or fewer spaces before it (like horseradish in the above example, which links onto the wasabi group above it because wasabi is the first item above it to not have more spaces than horseradish)
You must preserve the indenting level of each input item in your output
Tabs in the output are disallowed
The first line of the input will never be indented
Your program must handle at least one of all-uppercase and all-lowercase strings; it doesn't have to handle both.


Scoring

This is a code-golf, so the answer which uses the fewest bytes wins.
Python 2, 117 bytes



lambda S:[s[-1]for s in sorted(reduce(lambda t,s:t+[[v for v in t[-1]if v.count(' ')&lt;s.count(' ')]+[s]],S,[[]]))[1:]]


Try it online!

Takes as input a list of strings; and outputs a list of strings, sorted as required.

The idea is to turn each element into a list which contains the "absolute path" as a list; and then let Python handle the sorting. E.g. if the input is:

[
 'a',
 ' c',
 '  d',
 ' b'
]


Then via the reduce(), we convert to a list of lists:

[
 ['a'],
 ['a',' c'],
 ['a',' c', '  d'],
 ['a',' b']
]


which gets sorted as:

[
 ['a'],
 ['a',' b']
 ['a',' c'],
 ['a',' c', '  d'],
]


and then output the last element of each list in the list-of-lists to get:

[
 'a',
 ' b'
 ' c',
 '  d',
]