finished coordinate query including sorting by number of references