Many control algorithms for formation of robot swarms are often inspired from animal swarms. However, these algorithms are derived by simply imitating the behaviors of animal swarms instead of directly applying intrinsic principles because of the capability gaps between animals and robots. Here we experimentally proved that the principle of differential adhesion hypothesis in cell biology can be directly applied to the formation of robot swarms. Like cell collectives, swarms of sensor-less robots aggregated and sorted in a self-organized manner. Based on this finding, we programmed robot swarms to form functional morphologies via tuning their adhesion. This work advances swarm robotics in forming functional morphologies and enables us to quantitatively investigate morphogenesis in cell collectives using robot swarms.