The order of sharps and flats in a key signature is always the same: the sharps follow the sequence F C G D A E B and the flats follow the reverse order, B E A D G C F. Writing the accidentals in any other order is considered a spelling mistake in music notation. The order is not arbitrary: it comes from the circle of fifths, so that each new key adds one accidental at the end of the sequence. Below you will find the full order, how each key signature is written on the staff (UK: stave) and a trick to memorize it.
Order of sharps: F C G D A E B
The sharps appear one at a time, always in this order, going up by perfect 5th each time:
- F♯
- C♯
- G♯
- D♯
- A♯
- E♯
- B♯
Here is each sharp key signature written on the staff, from 1 to 7 sharps (treble clef):
Order of flats: B E A D G C F
The flats follow exactly the reverse order of the sharps, going down by fifths:
- B♭
- E♭
- A♭
- D♭
- G♭
- C♭
- F♭
And here is each flat key signature on the staff, from 1 to 7 flats (treble clef):
A trick to memorize it
You do not need to memorize fourteen accidentals: one sequence and its reverse are enough.
- Sharps (F C G D A E B). Use the saying "Father Charles Goes Down And Ends Battle". Each letter is a perfect 5th above the one before it.
- Flats (B E A D G C F). It is the same sequence read backwards ("Battle Ends And Down Goes Charles's Father"; the first four letters also spell BEAD). If you know the order of the sharps, you already know the order of the flats: just reverse it.
The underlying reason is the circle of fifths: sharps keep going up by fifths and flats keep going down by fifths. That is why the order never changes.