With one single LEGO motor, MisterFitzGibbon built this brick sorting machine - "LEGO Brick-Sorting Bird" as he called it. A true masterpiece!
Using just one motor running always in the same direction and no sensors or programmable brick, this amazing model picks the next brick in the queue and sorts them by size.
The description available from YouTube, provides some explanation on the working principles used. It even gives a few hints if you want to build your own and extend it to handle more brick sizes.
"When the beak can close no further, power is transferred to turning the bird. If the beak closes on a larger brick, it will begin turning earlier, and thus turns further, before a crank pushes the bird into reverse. In reverse the bird drops the brick and then returns for another.
For anyone who wants to make one, just remember that the axel on which the bird turns is the stiffer black peg. A grey one would cause the bird to turn before picking up the brick. Also, by extending the neck and the length of the beak you can make a bird which will sort more sizes."
My jaw almost fallen when I saw it for the first time, some months ago...