If I have a case class like this
case class Foo(bar: Option[String])
why does this work
scala> val l = List(Foo(Some("b")), Foo(Some("a")), Foo(Some("c")))
l: List[Foo] = List(Foo(Some(b)), Foo(Some(a)), Foo(Some(c)))
scala> l.sortBy(_.bar)
res1: List[Foo] = List(Foo(Some(a)), Foo(Some(b)), Foo(Some(c)))
but not this
scala> l.sortWith((x,y) => x.bar > y.bar)
<console>:11: error: value > is not a member of Option[String]
l.sortWith((x,y) => x.bar > y.bar)
If I want to sort a List of Option[String] in descending order, is it just simpler to use sortBy and then reverse the list?