Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created June 17, 2011 01:36
Show Gist options
  • Save xuwei-k/1030701 to your computer and use it in GitHub Desktop.
Save xuwei-k/1030701 to your computer and use it in GitHub Desktop.
Listのsortのてすとぉーーーー
def sortTest{
val list = List(1,8,3,5,0)
println( list.sorted ) //List(0, 1, 3, 5, 8)
implicit val ascOrdering = new Ordering[Int]{
def compare(x:Int,y:Int) = if( x > y ) -1 else if( x < y) +1 else 0
}
println( list.sorted ) //List(8, 5, 3, 1, 0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment