Is there a reason why there is no implicit Ordering for Lists in Scala?
val lists = List(List(2, 3, 1), List(2, 1, 3)) lists.sorted error: could not find implicit value for parameter ord: Ordering[List[Int]]
EDIT
Yes, my question is why there is no built-in Ordering that's already implicitly in scope. To me, it seems obvious that the second list should be "less than" the first list since the items at 0 are equal and the second list has the lower item at 1. I was wondering if maybe it's that there's no good answer when the Lists are two different sizes.
I think it's an oversight. Lexicographic ordering does make sense on Seqs. We should add it to the standard library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With