# Task
 Some people are standing in a row in a park. There are trees between them which cannot be moved. 
 
 Your task is to rearrange the people by their heights in a non-descending order without moving the trees.

# Example

 For `a = [-1, 150, 190, 170, -1, -1, 160, 180]`, the output should be

 `[-1, 150, 160, 170, -1, -1, 180, 190]`.

# Input/Output


 - `[input]` integer array `a`

    If a[i] = -1, then the ith position is occupied by a tree. Otherwise a[i] is the height of a person standing in the ith position.

    Constraints:

    `5 ≤ a.length ≤ 30,`

    `-1 ≤ a[i] ≤ 200.`


 - `[output]` an integer array

    `Sorted` array a with all the trees untouched.

Difficulty: introductory

Starter code:

def sort_by_height(a):
	

Solutions:
def sort_by_height(a):
    s = iter(sorted(x for x in a if x != -1))
    return [x if x == -1 else next(s) for x in a]

def sort_by_height(arr):
    heights = iter(sorted(i for i in arr if i > 0))
    for idx, i in enumerate(arr):
        if i > 0:
            arr[idx] = next(heights)
    return arr

def sort_by_height(a):
  people = iter(sorted([i for i in a if i != -1]))
  return [i if i == -1 else next(people) for i in a]

def sort_by_height(a):
    people = iter(sorted(n for n in a if n != -1))
    return [next(people) if n != -1 else n for n in a]

def sort_by_height(a):
    filtered = list(sorted(filter(lambda x: x != -1, a), key=lambda x: -x))
    return [-1 if i == -1 else filtered.pop() for i in a]

def sort_by_height(arr):
    s=sorted(n for n in arr if n!=-1)
    return [n if n==-1 else s.pop(0) for n in arr]

def sort_by_height(a):
    people = sorted([j for j in a if j != -1])
    for i in range(len(a)):
        if a[i] != -1:
            a[i] = people.pop(0)
    return a
        


def sort_by_height(a):
    it = iter(sorted([x for x in a if x >= 0]))
    return [x if x < 0 else next(it) for x in a]

def sort_by_height(a):
    list_index = [x for x,i in enumerate(a) if i == -1] 
    list_sorted = sorted([i for x,i in enumerate(a) if i != -1]) 
    
    for new_item in list_index:
        list_sorted.insert(new_item, -1)
        
    return list_sorted

def sort_by_height(a):
    h, k = sorted([i for i in a if i!=-1]), []
    for i in a:
        if i!=-1:
            k+=[h[0]]
            h=h[1:]
        else:
            k+=[i]
    return k