Long-range orientational order in a two-dimensional degenerate system of dipoles on a square lattice