Brit a bed made with the sheet folded back halfway down as a practical joke, so that the occupant cannot lie out straight
Possibly a corruption of the French phrase cap-à-pie ‘from head to foot’, although the association of meaning is not obvious. There may be no historical connection with apple-pie order