I need to convert the list to set but in order. But I am getting the set that is not in order.
def toset(list: List[Int]): Int = {
var newset = Set.empty[Int]
for (i <- list){
newset += i
}
}
Then, if I do list = List[Int] (4,6,2,1,7) and toset(list), I will get newset = Set(1,6,2,7,4) instead of newset = Set (4,6,2,1,7)