The explanation above is incorrect. The assumption about the spacing of atoms in matter is correct, but the reasoning behind how sound travels through materials is wrong. Speed travels faster in denser materials. Since atoms are packed together in solids, any energy imparted upon an atom (a sound wave striking the atom) is transferred to its neighbor atom quickly. In contrast since atoms are free to move in gases, when it is struck it may have to travel a distance before it strikes another atom, in the process losing total energy - slowing the sound wave. If we look up the speed of sound in different materials we see the speed is greatest in solids, then liquids, and finally gases.
Copper 3901(m/s)
Kerosene 1324 (m/s)
Helium 965 (m/s)
Copper 3901(m/s)
Kerosene 1324 (m/s)
Helium 965 (m/s)