Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ordering implicit object to DateTime DateMidnight etc #1

Open
azzoti opened this issue Nov 5, 2009 · 0 comments
Open

Add Ordering implicit object to DateTime DateMidnight etc #1

azzoti opened this issue Nov 5, 2009 · 0 comments

Comments

@azzoti
Copy link

azzoti commented Nov 5, 2009

Recent addition to Scala 2.8pre is the SeqLike.sortBy method which allows you to say

listOfPerson.sortBy(person => person.name)
listOfPerson.sortBy(person => person.shoeSize)
listOfPerson.sortBy(person => person.salary)

but not currently
listOfPerson.sortBy(person => person.dob)

The String/Int/Double sorts works because of implicit object definitions in Ordering.scala. See http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/library/scala/Ordering.scala?view=markup from "trait FloatOrdering extends Ordering[Float]".

Suggestion: Add similar implicit objects to Scala-Time in the same style os those in Ordering.scala
For example:
trait DateTimeOrdering extends Ordering[DateTime] {
def compare(x: DateTime, y: DateTime) = x.compareTo(y)
}
implicit object DateTime extends DateTime Ordering

Simple example of usage shown at end of http://quoiquilensoit.blogspot.com/2009/11/c-linq-orderby-scala-sortwith-and.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant