Out of sorts. Not in good health and spirits. The French être dérangé explains the metaphor. If cards are out of sorts they are deranged, and if a person is out of sorts the health or spirits are out of order.
In printers' language it means out of some particular letter, in which case they substitute for a time another letter.