Last active
June 2, 2020 07:37
-
-
Save RyanSusana/8e9217cf2a11c78237c3c8c577ba3221 to your computer and use it in GitHub Desktop.
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
def insertionSort(xs : List[Int]) : List[Int] = { | |
xs match{ | |
case Nil => Nil | |
case x :: xs1 => insert(x, isort(xs1)) | |
} | |
} | |
def insert(x : Int, xs : List[Int]) : List[Int] = { | |
xs match { | |
case Nil => List(x) | |
case y :: xs1 => | |
if(y >= x) x :: xs | |
else y :: insert(x, xs1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment