added sorting endpoint. Why is Scala so horrible?