We consider high-dimensional sparse regression problems in which we observe y = X. + z, where X is an n . p design matrix and z is an n-dimensional vector of independent Gaussian errors, each with variance .². Our focus is on the recently introduced SLOPE estimator [Ann. Appl. Stat. 9 (2015) 1103-1140], which regularizes the least-squares estimates with the rank-dependent penalty${\Sigma _{1 \leqslant i \leqslant {p^{{\lambda _i}}}}}|\hat \beta {|_{(i)}}$, |..|(i) is the ith largest magnitude of the fitted coefficients. Under Gaussian designs, where the entries of X are i.i.d. N(0,1/n), we show that SLOPE, with weights .i just about equal to .· ..¹ (1 . iq/(2p)) [..¹(.) is the orth quantile of a standard normal and q is a fixed number in (0,1)] achieves a squared error of estimation obeying sup .(||..SLOPE - .||² > (1 + .)2.²klog(p/k)).0 ||.||..k as the dimension p increases to ., and where . > 0 is an arbitrary small constant. This holds under a weak assumption on the l.-sparsity level, namely, k/p . 0 and (k log p)/n . 0, and is sharp in the sense that this is the best possible error any estimator can achieve. A remarkable feature is that SLOPE does not require any knowledge of the degree of sparsity, and yet automatically adapts to yield optimal total squared errors over a wide range of l.-sparsity classes. We are not aware of any other estimator with this property.