The first pair of prelude and fugue is in C major, the second in C minor, the third in C-sharp major, and so on, meaning that the key signatures go from C up to B-flat in a chromatic (half steps) order.
Prelude and Fugue in C Major, BWV 846 (WTC I)
J. S. Bach composed two books known as The Well-Tempered Clavier (Das Wohltemperierte Klavier). Each of these books contains 24 pairs of preludes and fugues, in all major and minor keys. The first book is dated from 1722, and the second one from 1742.
The first pair of prelude and fugue is in C major, the second in C minor, the third in C-sharp major, and so on, meaning that the key signatures go from C up to B-flat in a chromatic (half steps) order.