Another solution

from: http://www.ics.uci.edu/~eppstein/161/python/closestpair.py