"highest point," Old English top "summit, crest, tuft," from Proto-Germanic *toppa- (source also of Old Norse toppr "tuft of hair," Old Frisian top "tuft," Old Dutch topp, Dutch top, Old High German zopf "end, tip, tuft of hair," German Zopf "tuft of hair"); no certain connections outside Germanic except a few Romanic words probably borrowed from Germanic.
Few Indo-European languages have a word so generic, which can be used of the upper part or surface of just about anything. More typical is German, which has Spitze for sharp peaks (mountains), oberfläche for the upper surface of flat things (such as a table). The meaning "highest position" is from 1620s; the meaning "best part" is from 1660s. The sense of "dominant sexual partner" is by 1961.
To go over the top is World War I slang for "start an attack," in reference to the top of the trenches; as "beyond reasonable limits, too far" it is recorded from 1968. Top of the world as "position of greatest eminence" is from 1670s. Top-of-the-line (adj.) is by 1950.
hat n.
Old English hæt "hat, head covering" (variously glossing Latin pileus, galerus, mitra, tiara), from Proto-Germanic *hattuz "hood, cowl" (source also of Frisian hat, Old Norse hattr, höttr "a hood or cowl"), of uncertain etymology; it has been compared with Lithuanian kuodas "tuft or crest of a bird" and Latin cassis "helmet" (but this is said to be from Etruscan).
To throw (one's) hat in the ring was originally (1847) to take up a challenge in prize-fighting. To eat one's hat (1770), expressing what one will do if something he considers a sure thing turns out not to be, is said to have been originally eat Old Rowley's [Charles II's] hat.