Ordering-Based Causal Discovery for Linear and Nonlinear Relations