System (1) for sorting livestock, comprising a sorting compartment (40) surrounded by delimitations, an access port (3) to the sorting compartment and two or more exit ports (14a14b14c14d) from the sorting compartment, and at least one movable sorting wall (11a11b11c), such as a sorting gate, wherein the entry port and the exit port each have at least one gate leaf which is movable between a closed position and one or more pass positions, also comprising first counting means for ascertaining a passage of an animal through the access port and second, third, etc. counting means for ascertaining a passage of an animal through a respective exit port, and a programmable control unit (15) to which the aforementioned counting means are operatively connected, wherein the system is also provided with first closing means (9a,9b) for holding the access port in a closed position, wherein the system further comprises drive means for moving the sorting wall from a position steering the livestock from the access port to a first exit port to a position steering the livestock from the access port to a second exit port, wherein the control unit is configured for activating the drive means for the sorting wall on the basis of a comparison of the data from the second counting means with the data from the first counting means.