We study a simple algorithm inspired by the Brazil nut effect for achieving segregation in a swarm of mobile robots. The algorithm lets each robot mimic a particle of a certain size and broadcast this information locally. The motion of each particle is controlled by three reactive behaviors: random walk, taxis, and repulsion by other particles. The segregation task requires the swarm to self- ranked by particle size (e.g., annular structures or stripes). Using a physics-based computer simulation, we study the segregation performance of swarms of 50 mobile robots. The robots represent particles of three different sizes. We first analyze the problem of how to combine the basic behaviors so as to minimize the percentage of errors in rank. We then show that the system is very robust with respect to noise on inter-robot perception and communication. For a noise-level of 50%, the mean percentage of errors in rank is 1%. Moreover, we investigate a simplified version of the control algorithm, which does not rely on communication. Finally, we show that the mean percentage of errors in rank decreases exponentially as the particles’ size ratio increases. As the error is bounded, one can achieve 100% error-free segregation. The reduction in error, however, comes at the expense of an increase in the required sensing/communication range.