This page is no longer maintained — Please continue to the home page atwww.scala-lang.org
/* Defines a new method 'sort' for array objects */object implicitsextends Application {implicitdef arrayWrapper[A : ClassManifest](x: Array[A]) =new {def sort(p: (A, A)=> Boolean) = { util.Sorting.stableSort(x, p); x } }val x = Array(2, 3, 1, 4) println("x = "+ x.sort((x: Int, y: Int)=> x < y))}
Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland