Optimizing ROC Curves with a Sort-Based Surrogate Loss for Binary Classification and Changepoint Detection