We construct bi-invariant total orderings of residually torsion-free nilpotent groups by using Chen's iterated integrals. This construction can be seen as a generalization of the Magnus ordering of the free groups, and equivalent to the classical construction which uses an iteration of central extensions. Our geometric construction provides a connection between bi-orderings and the rational homotopy theory. (C) 2011 Elsevier B.V. All rights reserved.