Repository: Qiskit/qiskit-terra (python)

Issue:
Add `qubits` and `clbits` arguments to QuantumCircuit.from_instructions
### What should we add?

These arguments can be used to initialize the QuantumCircuit. That way the user can control the ordering of `circuit.qubits`; otherwise, they will be in the order that the qubits are added.

Pull request description:
add qubits and clbits args to QuantumCircuit.from_instructions
<!--
⚠️ If you do not respect this template, your pull request will be closed.
⚠️ Your pull request title should be short detailed and understandable for all.
⚠️ Also, please add a release note file using reno if the change needs to be
  documented in the release notes.
⚠️ If your pull request fixes an open issue, please link to the issue.

- [ ] I have added the tests to cover my changes.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the CONTRIBUTING document.
-->

### Summary
Fixes #9048 


### Details and comments




Patch:
diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py
index e982a8046..5c1f4134a 100644
--- a/qiskit/circuit/quantumcircuit.py
+++ b/qiskit/circuit/quantumcircuit.py
@@ -294,6 +294,8 @@ class QuantumCircuit:
             | tuple[qiskit.circuit.Instruction, Iterable[Qubit], Iterable[Clbit]]
         ],
         *,
+        qubits: Iterable[Qubit] = (),
+        clbits: Iterable[Clbit] = (),
         name: Optional[str] = None,
         global_phase: ParameterValueType = 0,
         metadata: Optional[dict] = None,
@@ -302,6 +304,10 @@ class QuantumCircuit:
 
         Args:
             instructions: The instructions to add to the circuit.
+            qubits: Any qubits to add to the circuit. This argument can be used,
+                for example, to enforce a particular ordering of qubits.
+            clbits: Any classical bits to add to the circuit. This argument can be used,
+                for example, to enforce a particular ordering of classical bits.
             name: The name of the circuit.
             global_phase: The global phase of the circuit in radians.
             metadata: Arbitrary key value metadata to associate with the circuit.
@@ -312,6 +318,14 @@ class QuantumCircuit:
         circuit = QuantumCircuit(name=name, global_phase=global_phase, metadata=metadata)
         added_qubits = set()
         added_clbits = set()
+        if qubits:
+            qubits = list(qubits)
+            circuit.add_bits(qubits)
+            added_qubits.update(qubits)
+        if clbits:
+            clbits = list(clbits)
+            circuit.add_bits(clbits)
+            added_clbits.update(clbits)
         for instruction in instructions:
             if not isinstance(instruction, CircuitInstruction):
                 instruction = CircuitInstruction(*instruction)


Test patch:
diff --git a/test/python/circuit/test_circuit_operations.py b/test/python/circuit/test_circuit_operations.py
index 4b3655502..8b956482f 100644
--- a/test/python/circuit/test_circuit_operations.py
+++ b/test/python/circuit/test_circuit_operations.py
@@ -1187,6 +1187,37 @@ class TestCircuitOperations(QiskitTestCase):
         self.assertEqual(circuit_tuples, expected)
         self.assertEqual(circuit_tuples_partial, expected)
 
+    def test_from_instructions_bit_order(self):
+        """Test from_instructions method bit order."""
+        qreg = QuantumRegister(2)
+        creg = ClassicalRegister(2)
+        a, b = qreg
+        c, d = creg
+
+        def instructions():
+            yield CircuitInstruction(HGate(), [b], [])
+            yield CircuitInstruction(CXGate(), [a, b], [])
+            yield CircuitInstruction(Measure(), [b], [d])
+            yield CircuitInstruction(Measure(), [a], [c])
+
+        circuit = QuantumCircuit.from_instructions(instructions())
+        self.assertEqual(circuit.qubits, [b, a])
+        self.assertEqual(circuit.clbits, [d, c])
+
+        circuit = QuantumCircuit.from_instructions(instructions(), qubits=qreg)
+        self.assertEqual(circuit.qubits, [a, b])
+        self.assertEqual(circuit.clbits, [d, c])
+
+        circuit = QuantumCircuit.from_instructions(instructions(), clbits=creg)
+        self.assertEqual(circuit.qubits, [b, a])
+        self.assertEqual(circuit.clbits, [c, d])
+
+        circuit = QuantumCircuit.from_instructions(
+            instructions(), qubits=iter([a, b]), clbits=[c, d]
+        )
+        self.assertEqual(circuit.qubits, [a, b])
+        self.assertEqual(circuit.clbits, [c, d])
+
     def test_from_instructions_metadata(self):
         """Test from_instructions method passes metadata."""
         qreg = QuantumRegister(2)