Optimize recombination step in paulistring optimizer (#1834)
Optimize recombination step in paulistring optimizer (#1834)

Before optimization: 

```bash
2019-07-16 09:16:20,584 - INFO - reading qasm file...
2019-07-16 09:16:25,140 - INFO - parsed qasm file: 13392 ops
2019-07-16 09:18:24,564 - INFO - optimized circuit: 1854 ops in 119.42398381233215 
2019-07-16 09:18:24,654 - INFO - stats: misses 74115, dupes: 6505723
```
which means that 98.87% of comparisons has been done at least twice.

Insight: we can  just sort the nodes of the frontier _once_, based on the best placement possible for a given paulistring instead of repeatedly reevaluating them. Why? 

1.) because the nodes of the frontier (rightmost nodes in the DAG) are commuting with each other, so they can be sorted independently of each other and each other's predecessors in the DAG and we can insert all the nodes in the frontier first.
2.)  sorting the nodes seems to guarantee the insertion indices to be sorted _as well_ , which is great, because then we don't have to worry about recalculating the best insertion spot for a node (as a previous insertion might have changed the circuit?) as I start with the furthest one, that leaves the circuit the same before, where the next node can come in...- why does sorting guarantee the insertion indices to be sorted? Because the best placements are where the paulistrings become of length one - and within those placements the insertion index is sorted. 

Thus, we can just insert the nodes in the sorted frontier to their best placements and only then draw the new frontier. 

This gives us: 

```bash
2019-07-16 10:00:49,046 - INFO - reading qasm file...
2019-07-16 10:00:53,691 - INFO - parsed qasm file: 13392 ops
2019-07-16 10:01:46,964 - INFO - optimized circuit: 1854 ops in 53.273059129714966 
2019-07-16 10:01:47,044 - INFO - stats: misses 843915, dupes: 31864
```

which is 3% duplication and >50% time reduction. 

balopat/Cirq,quantumlib/Cirq,quantumlib/Cirq,balopat/Cirq,quantumlib/Cirq,quantumlib/Cirq,balopat/Cirq,quantumlib/Cirq