- Home /
GetFiles Sort Order (Incremental)
Hello,
I have some files in a directory, labelled:
1.png
2.png
3.png
4.png
[...]
10.png
11.png
12.png
I'm importing them into Unity by using the 'GetFiles' IO extension method. I need them to be read in that order, but by default, the order is:
1.png | 10.png | 11.png | 12.png | 2.png | 3.png
I understand why it's doing that, but its not helpful. I'd like to sort them. So I tried using a Sort method:
_supported.Sort(SortByIncremental);
int SortByIncremental(FileInfo _f1, FileInfo _f2){
return _f1.Name.CompareTo(_f2.Name);
}
But this yields the same results. Is there anyway I can fix this? Note, I can't change the name of the file itself from '1.png', to '01.png'.
Your answer

Follow this Question
Related Questions
How to sort a built-in array in the inspector? 2 Answers
Dynamic Turn Order and Display Based On Initiative Value (Javascript)? 2 Answers
How can I order an array of RaycastHits in reverse order of distance? 1 Answer
sort a List of GameObjects by distance? 1 Answer
IComparable returning unpredictable Sort() results 0 Answers