Convert List of Ints to a SortedSet in Scala

Viewed 12405

If I have a List of Ints like:

val myList = List(3,2,1,9)

what is the right/preferred way to create a SortedSet from a List or Seq of Ints, where the items are sorted from least to greatest?

If you held a gun to my head I would have said:

val itsSorted = collection.SortedSet(myList)

but I get an error regarding that there is no implicit ordering defined for List[Int].

4 Answers
Related