Where did "that really takes the biscuit/cake" come from? [closed]

"Take the cake" comes from this definition of "cake" found in the OED:

Cake is often used figuratively in obvious allusion to its estimation (esp. by children) as a ‘good thing’, the dainty, delicacy, or ‘sweets’ of a repast. So cakes and ale, cake and cheese (Scotl.). to take the cake, (†U.S. cakes): to carry off the honours, rank first; often used ironically or as an expression of surprise. Cf. biscuit n. 1d.

The plural (now obsolete) "take the cakes" seems to predate the singular:

Big Peach.—We were presented with a peach that grew on the farm of Capt. W. H. Turner, two miles from this place, which measured eleven inches in circumference, and weighing three quarters of a pound—beat this and take the cakes.
Lexington Union (Lexington, Mississippi), August 2nd, 1839

Sherriff Moore takes the cake for the first wheat-harvesting in Ransom county.
Lisbon (Dakota Territory) Star July 25th, 1884

"Take the biscuit" comes a little later and is British:

Take the biscuit, to, a variation of "take the cake"
A Dictionary of Slang, Jargon & Cant Embracing English, American, and Anglo-Indian Slang, Pidgin English, Gypsies' Jargon and Other Irregular Phraseology, 1897