The Riesz-Kantorovich formula for lexicographically ordered spaces