Skip to content

Instantly share code, notes, and snippets.

@HYChou0515
Created March 7, 2018 03:33
Show Gist options
  • Save HYChou0515/10fcb861583adb853f9832b172827908 to your computer and use it in GitHub Desktop.
Save HYChou0515/10fcb861583adb853f9832b172827908 to your computer and use it in GitHub Desktop.
unique sort using scala
//unique sort using scala
object Main extends App {
val array=Array(5,4,7,6,5,5,4,3,3,3,2,5,5,1,2)
util.Sorting.quickSort(array)
val newArray = array.foldRight(List.empty[Int]){
case (a, b) =>
if (!b.isEmpty && b(0) == a)
b
else
a :: b
}
for(s <- newArray) println(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment