The phenomenon I'm asking about can be seen in this veritusium video. The balls were just dumped in randomly, and they are buffeted by wind and currents, so how do they settle into clean lattice-like structures? Can the mechanics of this phenomenon be applied to other phenomena?
The "crystals" are likely due to locally jammed structures. Jammed structures show up a lot in granular media when objects are packed together so that they all prevent each other from moving. As the fraction filled by the spheres increases, they are increasingly forced into locally jammed configurations since there are fewer and fewer options available. Since the density increases these jammed structures are also regular crystals.