Created
February 24, 2014 18:41
-
-
Save tuxdna/9194264 to your computer and use it in GitHub Desktop.
simple comparator example in Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package oop | |
object testoop { | |
def main(args: Array[String]) { | |
val persons = Array( | |
new Person(2, "amar"), | |
new Person(3, "akbar"), | |
new Person(1, "anthony"), | |
new Person()) | |
println(persons mkString (", ")) | |
println(persons.sortBy(f => f.age) mkString (", ")) | |
println(persons.sortBy(f => f.name) mkString (", ")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment