We investigate the clustering of afterglow light curves observed at X-ray and optical wavelengths. We have constructed a sample of 61 bursts with known distance and X-ray afterglow. This sample includes bursts observed by BeppoSAX, XMM-Newton, Chandra, and Swift. We correct the light curves for cosmological effects and compare the observed X-ray fluxes 1 day after the burst. We check for correlations between the observed flux and the burst spectral and temporal properties. We confirm the previous result of Boer & Gendre that X-ray afterglow light curves cluster in luminosity, even when we consider the last Swift data. We observe this clustering only for the afterglow light curves; the inclusion of prompt-related data broadens the distribution. A similar clustering is observed for the optical light curves; gamma-ray burst (GRB) sources can be divided into three classes, namely, optically and X-ray bright after-glows, optically and X-ray dim ones, and optically bright but X-ray dim ones. We argue that this clustering is related to the fireball total energy, the external medium density, and the fraction of fireball energy going into relativistic electrons and magnetic fields. These parameters can be either fixed to a standard value or correlated. We finally propose a method for the estimation of the GRB source redshift based on the observed X-ray flux 1 day after the burst and optical properties. Using this method, we compute a redshift of 1.4 +/- 0.2 for GRB 980519 and of 1.9 +/- 0.3 for GRB 040827. We tested this method on three recently detected Swift GRBs with known redshift, and found it in good agreement with the reported distance from optical spectroscopy.