Z
Z
Zefirot2022-01-09 14:57:25
C++ / C#
Zefirot, 2022-01-09 14:57:25

How to reorder prefabs by name in an array?

I get prefabs from resources, there they are in this order

Test-1, Test-2, .... Test-10, Test-11...

I get them like this
Test[] ArrayTest = Resources.LoadAll<Test>(Path);
In general, I get them in this order
Test-1, Test-10, Test-11, Test-2.......

How can I reorder them so that they are in order in my array?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
edward_freedom, 2022-01-09
@Zefirot

var array = new List<string>()
            {
                "Test-2",
                "Test-1",
                "Test-5",
                "Test-4",
                "Test-3"
            };

Debug.WriteLine(string.Join(Environment.NewLine, array.OrderBy(item => item)));

Conclusion
Test-1
Test-2
Test-3
Test-4
Test-5

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question