In this paper we present an extension of Moreau's sweeping process for higher order systems. The dynamical framework is carefully introduced, qualitative, dissipativity, stability, existence, regularity and uniqueness results are given. The time-discretization of these nonsmooth systems with a timestepping algorithm is also presented. This differential inclusion can be seen as a mathematical formulation of complementarity dynamical systems with arbitrary dimension and arbitrary relative degree between the complementaryslackness variables. Applications of such high-order sweeping processes can be found in dynamic optimization under state constraints and electrical circuits with ideal diodes.