Why do we say “that takes the cake”?

The meaning is pretty simple, often said in competition when someone really does something exceptional which surely means they win…But the actual origins of the saying comes from the parties of Afro Americans in the dancing halls around the US. Afro Americans in the Old South would show off their dancing skills in dance halls, these contests, if you can call them that, were called Cakewalks. Because the participants were to dance around a cake in the middle of the hall which the winner would get. The participants were people of any race, any gender and couples for most of the time. A panel of judges would watch the dance, with the winner than decided. He/She would take the cake. Normally the most innovative and elegant dancers would take the coveted cake.