Molecular recognition plays an important role in nature, with perhaps the best known example being the complementarity exhibited by pairs of nucleobases in DNA. Studies of self-assembling and self-organizing systems based on molecular recognition are often performed at the molecular level, however, and any macroscopic implications of these processes are usually far removed from the specific molecular interactions. Here, we demonstrate that well-defined molecular-recognition events can be used to direct the assembly of macroscopic objects into larger aggregated structures. Acrylamide-based gels functionalized with either host (cyclodextrin) rings or small hydrocarbon-group guest moieties were synthesized. Pieces of host and guest gels are shown to adhere to one another through the mutual molecular recognition of the cyclodextrins and hydrocarbon groups on their surfaces. By changing the size and shape of the host and guest units, different gels can be selectively assembled and sorted into distinct macroscopic structures that are on the order of millimetres to centimetres in size.