A three-dimensional mathematical model is used to determine the effects of adhesion and cell signalling on cell movements during the aggregation and slug stages of Dictyostelium discoideum (Dd) and to visualize cell sorting. The building blocks of the model are individual deformable ellipsoidal cells, where movement depends on internal parameter state (cell size and stiffness) and on external cues from the neighboring cells, extracellular matrix, and chemical signals. Cell movement and deformation are calculated from equations of motion using the total force acting on each cell, ensuring that forces are balanced. The simulations show that the sorting patterns of prestalk and prespore cells, emerging during the slug stage, depend critically on the type of cell adhesion and not just on chemotactic differences between cells. This occurs because cell size and stiffness can prevent the otherwise faster cells from passing the slower cells. The patterns are distinctively different when the prestalk cells are more or less adhesive than the prespore cells. These simulations suggest that sorting is not solely due to differential chemotaxis, and that differences in both adhesion strength and type between different cell types play a very significant role, both in Dictyostelium and other systems.