Initially, it can be represented graphically as follow:
Then, the sort is applied myList.Sort();
Finally, when you did: myList' = myList2
, you lost the one of the reference but not the original and the collection stayed sorted.
If you use by reference (ref
) then myList'
and myList
will become the same (only one reference).
Note: I use myList'
to represent the parameter that you use in ChangeList
(because you gave the same name as the original)