Optical properties of nanostructures: From random to periodic