Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.26 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def sortTest{
  2.  
  3.   val list = List(1,8,3,5,0)
  4.  
  5.   println( list.sorted ) //List(0, 1, 3, 5, 8)
  6.  
  7.   implicit val ascOrdering = new Ordering[Int]{
  8.     def compare(x:Int,y:Int) = if( x > y ) -1 else if( x < y) +1 else 0
  9.   }
  10.  
  11.   println( list.sorted ) //List(8, 5, 3, 1, 0)
  12.  
  13. }