In the session titled #GrammarTrivia: Omitting If, we have learned the inversions of subjects and verbs in conditional sentences. When a conditional sentence contains should, were, or had, the subject and verb of the if-clause are inverted. Inversion is also possible in sentences with negative expressions or comparisons.
(More on Omitting If: https://englishtips4u.com/2018/11/10/grammartrivia-omitting-if/)
1) Inversion with Negative Expressions
A negative expression, when it precedes a subject and verb, causes them to be inverted. It is to emphasize the negative element of the sentence.
List of negative expressions:
1. Never were they so enthusiastic.
2. Hardly does she attend the class.
2) Inversion with Comparisons
Inverting the subject and verb of a sentence which contains a comparison is optional and rather formal.
1. China is larger than Japan.
2. China is larger than Japan is.
3. China is larger than is Japan.
Betty Schrampfer Azar, Understanding and Using English Grammar: Third Edition
Deborah Phillips, Longman Complete Course for the TOEFL Test