The phrase “to take the cake” means to receive or merit a prize or honor; hence, to excel at something.
This expression did not arise from the “cakewalk,” but the cakewalk got its name from the expression. Even two hundred years ago “cake” denoted an award or honor of some sort, and he who received it, “took the cake.”
American usage can be traced back a hundred years.
The cakewalk, originally a Negro entertainment in which couples competed for a cake by the grace or style of walking, came into notice only in the last quarter of the nineteenth century.