Lots of rules and guidelines in music have exceptions. The order of flats or sharps in a key signatures do NOT have exceptions. They are either in the below order, or they are wrong. That's kind of helpful!
Key signatures tell us that the notes in the staff are natural unless they are changed by the key signature, or by a flat, sharp or natural within the notation. In that case, they are called an "accidental", and it lasts until the end of a measure. Often, composers or publishers with add a "courtesy" accidental after the measure to remind the musician that the previous accidental is no longer in effect. A key signature alters notes in any and all octaves with that note name, not just in the octave you find in the key signature.
The key signature not only tells us which notes to alter, but also tells can tell us what key our music is in. There are two ways to get this information, and you should learn both. One is to follow a formula for each situation, and get faster at that. The other is to simply memorize them. The more you do one, the easier the other one is. This is why you might find an indication in a key signature that does not effect any of the written notes. You still need that information to know the scale based on the key of the piece!
Sharps: FCGDAEB
If there is one sharp, it is F-sharp. If there are 2 sharps, they are F-sharp and C-sharp. If there are three sharps, they are F-sharp, C-sharp, and G-sharp...etc...
Flats: BEADGCF
If there is one flat, it is B-sharp. If there are 2 sharps, they are F-sharp and C-sharp. If there are three sharps, they are F-sharp, C-sharp, and G-sharp...etc...