- Home /
Sorting list of Transforms
i have a list with Cubes (Transforms), i need to sort it alphabetical (numerous)
The Cubes have Names from 1 to ... : 1 2 3 4 ...
i have the following code, but that wont work:
list.OrderBy(wp => wp.name);
what's the problem? whats wrong with this?
@DaveA, i've solved the problem with a different method
There is the answer for you here http://answers.unity3d.com/questions/147628/sort-array-of-transforms-by-name.html
I guess it is because the title says sort array of transform by name.
Answer by UnityExample · Oct 19, 2012 at 08:09 PM
i've sorted it now with a different method:
foreach (Transform item in waypointsListe)
{
if (item != null && item.name != "Waypoints")
{
waypointsListeFinal[int.Parse(item.name.ToString())] = item;
}
else if (item != null && item.name == "Waypoints")
{
waypointsListeFinal[0] = item;
}
}
i've just wrote it in a second array with the id's, works like i wanted it
Your answer
Follow this Question
Related Questions
use list of gameobjects transform in raycast 0 Answers
A node in a childnode? 1 Answer
How to add and sort a list of gameobjects by tag? 2 Answers
Collision delete 1 Answer