':type people: List[List[int]]
:rtype: List[List[int]]'

def reconstructQueue(self, people):

    people.sort(key=(lambda (h, k): ((- h), k)))
    blocks = [[]]
    for p in people:
        index = p[1]
        for (i, block) in enumerate(blocks):
            if (index <= len(block)):
                break
            index -= len(block)
        block.insert(index, p)
        if ((len(block) * len(block)) > len(people)):
            blocks.insert((i + 1), block[(len(block) / 2):])
            del block[(len(block) / 2):]
    return [p for block in blocks for p in block]
