Skip to content

Instantly share code, notes, and snippets.

View samgj18's full-sized avatar
🦒

Samuel samgj18

🦒
View GitHub Profile
def sorted[S >: T](implicit ordering: Ordering[S]): List[S] = {
/**
* sort(4, [], [1, 2, 3, 5])
* sort(4, [1], [2, 3, 5])
* sort(4, [2, 1], [3, 5])
* sort(4, [3, 2, 1], [5])
* [3, 2, 1].reverse ++ (4 :: [5])
*/
@tailrec