Self-assembly of functionalized nanoparticles into microarrays and gradients