The spectrum from a star is comparable to a bar-code on a grocery store item. For a bar-code, the thickness and location of the black lines allows a grocery store scanner to interpret important details about the item, such as brand, item, weight, quantity, or price. In the early 1900's, astronomers began photographing the spectra of a vast number of stars. At first, the diversity of spectral features was too confusing to explain, so they simply grouped similar appearing spectra together in classes designated by the letters of the alphabet (A,B,C,D, etc.). When a group of Harvard astronomers, led by Annie Cannon, discovered a smooth sequence of types of spectra, the already assigned letters fell into the sequence O,B,A,F,G,K,M. For finer discrimination, the classes are further divided into subclasses from 0-9. Within each class the spectra are similar, yet the various classes merge smoothly into one another. Therefore, a F9 star and a G0 star are more similar to each other than a G0 and G9.
Read more about the Harvard Women and the history of Stellar Spectral Classification.
Early Astronomical Uses of Photography - Henry Draper
The Harvard Observatory Program to Classify Stellar Spectra - Edward Pickering & Williamina Fleming
Annie Cannon and the 'Computers'
The Spectral Classification Sequence is a Temperature Sequence - Cecilia Payne-Gaposchkin
Other Spectral Types: R, N, S, L and T