We consider hereditary classes of graphs equipped with a total order. We provide multiple equivalent characterisations of those classes which have bounded twin-width. In particular, we prove that those are exactly the classes which avoid certain large grid-like structures and induced substructures. From this we derive that the model-checking problem for first-order logic is fixed-parameter tractable over a hereditary class of ordered graphs if, and -under common complexity-theoretic assumptions -only if the class has bounded twin-width. We also show that bounded twin-width is equivalent to the NIP property from model theory, as well as the smallness condition from enumerative combinatorics. We prove the existence of a gap in the growth of hereditary classes of ordered graphs. Furthermore, we prove a grid theorem which applies to all monadically NIP classes of structures (ordered or unordered), or equivalently, classes which do not transduce the class of all finite graphs.