Obviously, if you drop materials into water near the surface of the Earth, they sort according to densities, with the least dense materials near the surface, and the most dense materials near the bottom. Common sense suggests this is due to gravity, because the more dense a material is, the more mass it has per unit of volume, and therefore, the more it interacts with any gravitational field. This should cause the most dense materials to experience a greater force due to gravity, causing them to sink more than others.
So my question then has two parts, which is, (1) is this the correct explanation for the apparent sorting of densities, and (2) if so, then what happens in space when you don't have any appreciable gravity?