I have the following code:
// Order a list
var orderedList = myList.OrderBy(x => x.name);
// Take few elements to another list (copies as reference)
List<GameObject> myList2 = orderedList.Where(x => x.z == y).ToList();
// Rename the objects in myList2
foreach(stuff in myList2)
{
stuff.name = "Renamed";
}
The question is why after modifying a property of an object in the myList2 changes the order of orderedList?
For example if the ordered list was "a,b,c,d" and I took the "b" and "c" to myList2. Then the orderedList would be "a,d,Renamed,Renamed" instead of "a,Renamed, Renamed, d".