The Talmud [Shabbos 74a] points to a blatant contradiction in a Mishna:
“One who has [two types of] food before him may sort and eat, sort and place.
Thus, he is forbidden to sort and if he does, he is liable to bring a את ַט ַח
offering.”
Abayei’s explains the first quote of the Mishna that permits sorting addresses the case when the
following 3 conditions are present:
1- Sorting only for immediate consumption.
2- Sorting by hand.
3- Sorting food from refuse
While the latter part of the Mishna evokes the case if one of these conditions is missing.
The Shulchan Aruch [Shabbos 319:1] statutes:
One who separates food from refuse, or if two food types were placed in front
of one and he separated one from the other.
According to the above ruling, it is obvious the laws of sorting apply in both cases, when sorting food
from refuse or a food from another food. The classic case being, selecting a specific candy from a bag.
We will now analyze every condition and provide examples for a better understanding.
1- Immediate consumption
The Rama states: Sorting for the forthcoming meal is permitted. The Taz clarifies that all agree
about this ruling, and only the preparation for the upcoming meal is allowed. There are though several
time restrictions involved which we will clarify.
The Mishna Brura explains that what defines the permissibility to sort is not the amount of time that
has elapsed since the sorting, but rather the fact that it was performed prior to that meal. Therefore,
even if it is the last course of a long meal, the sorting can be performed before the meal.
Similarly, if the preparation of the meal requires an extensive number of hours, even sorting so far
before the Seuda is considered “for immediate consumption” and permitted.
The classic case is preparing egg salad for the Shabbos meal. Shelling the eggs is considered sorting
and is therefore under the above restrictions. Hence, on a regular Shabbos it can only be prepared
after exiting Shul. However, for a Sheva Brochos or for a caterer, as soon as the preparations for the
meal started it is allowed to prepare it, even if it is still hours to the meal. Concisely, once the
preparation for the upcoming meal started and will extend all the way till the meal [but not ending
more than half hour prior], sorting is permitted as it is considered “for immediate consumption”.