I’ve heard this expression many times, and understood it to mean someone was frustrated or not feeling well. However, I asked myself “what is a sort, and why would someone find themselves out of them?” I found a detailed explanation in World Wide Words.
“The most common story about this phrase refers to the printer’s word sorts for the individual metal characters in his boxes of type, so called because they have been arranged, each into its own compartment, with all of one kind together. It would obviously be a substantial inconvenience if a printer were to run out of a sort during composition. The problem with this story is that the figurative expression out of sorts is recorded much earlier than the printers’ term.” A second idea is that the saying came from saying that a pack of playing cards hadn’t been shuffled. The author isn’t convinced about this origin, and instead thinks the origin derives from Latin. “The Latin original of our word sort was applied to a piece of wood that was used for drawing lots…it developed into the idea of one’s fate, fortune or condition…It survived until shortly after Shakespeare’s time, until about the point that out of sorts is first found.