(a)
When actions involving a common question of law or fact are pending before the court, it may order a joint hearing or trial of any or all the matters in issue in the actions; it may order all the actions consolidated and it may make such orders concerning proceedings therein as may tend to avoid unnecessary costs or delay.
(b)
The court, in furtherance of convenience or to avoid prejudice, or when separate trials will be conducive to expedition and economy, may order a separate trial of any cause of action, including a cause of action asserted in a cross-complaint, or of any separate issue or of any number of causes of action or issues, preserving the right of trial by jury required by the Constitution or a statute of this state or of the United States.