The capacitors are connected parallel to each other.
Thus the equivalent capacitance is given by C = C1 +C2.
The charges stored in capacitor is given by Q = CV. The energy stored in each capacitor is given by
U = 1/2 CV2.

When the terminals of opposite polarity are connected together, the magnitude of net charge finally is equal to the difference of magnitude of charges before connection.

Let V be the final common potential difference across each.
The charges will be redistributed and the system attains a steady state when potential difference across each capacitor becomes same.

Note that because C1 V1 < C2 V2, the final charge polarities are same as that of C2 before connection.

Loss of energy

Note: the energy is lost as heat in the connected wires due to the temporary currents that flow while the charge is being redistributed.