Ah, the British ranking system... It dates back to the mid-1600s, in Cromwell's time. At that time - the Dutch wars really - the Royal Navy generally operated en masse, almost 100 ships of the line (both proper Navy ships and sufficiently big rented/commandeered merchantmen) taking part in a single battle sometimes - and as many on the enemy side too! To keep some semblance of control this large fleet was organized into an advance guard, the main body, and a rear guard, all of roughly equal strengt; rather similar to how an army was organized. And indeed, the admirals tended to be ex-generals from the New Model Army.
Anyway, obviously the van, main and rear bodies of the fleet all needed an admiral in charge. Each of the three admirals had two subordinate admirals, one rear and one vice admiral, to command the rear and advance parts of his subfleet respectively. This gave each admiral about ten ships under his immediate command which was more or less manageable even with the rudimentary signalling systems they had to work with.
So, three sets of three admirals, one set for each part of the fleet. For identification purposes each part of the fleet was given individually coloured flags, the rear body had a blue flag, the main body a red flag, the van a white flag, and the relevant admirals' command flags had the same colour as their fleet body's colour. The sailing order of the admirals, counted from the rear of the fleet was thus:
Rear body - all ships using a blue flag
-Rear admiral of the blue
-Admiral of the blue - overall command of the rear body
-Vice-admiral of the blue
Main body - all ships using a red flag
-Rear admiral of the red
-Admiral of the red - overall command of the main body AND of the whole fleet
-Vice admiral of the red
Advance guard - all ships using a white flag
- Rear admiral of the white
- Admiral of the white - overall command of the van
- Vice admiral of the white
So the red admirals were superior to the whites which were superior to the blues, and admirals were superior to vice admirals which were superior to rear admirals. A white vice admiral would be superior to a blue vice admiral but inferior to a red one.
The "fleet body" flags evolved into the familiar red, white, and blue ensigns we know from the Napoleonic era. The simple nine-step system of admirals obviously broke down once they appointed a tenth one (well, the eleventh, there was an Admiral of the Fleet but he was generally supposed to stay in his office in London rather than go to sea with the fleet; James Stuart, I am looking at you!), so that in the eighteenth century they would have any number of rear-admirals of the white running around the place at any given time. As long as they were not in the same fleet at the same time this was not an issue.
CapnMac, your comment about officers is quite correct - for the Army. The Navy was different; officers were rather more middle-class than nobility and certainly did not purchase their commisions. It must of course be said that having friends in the right places has never hurt anyone! Promotion in the Navy was based on ability (and connections - although all the "interest" in the world would help the truly incompentent only so much) and, past a certain point, seniority. Once you made "post" rank, captain, further promotion was a matter of stepping into dead men's shoes unless the powers that be increased the number of admiral's billets. Promotion from midshipman to lieutenant was one point where having friends came in handy; promotion from lieutenant to captain even more so. After that it was all on autopilot while hoping for "a bloody war and a sickly season" to kill off the old geezers ahead of you on the ladder so you could move ahead.
Admirals Nelson and Hood were sons of lower grade churchmen; Rodney was born into a poor, if well-connected family; John Jervis was the son of a barrister. They ended up with titles and money to go with their flags but they made it there the hard way.