Hi there,
Aside from your data being inconsistent between your two lists (see 9.bmp. First list has 2\\, 2nd list has 4\\ - this affects the ordering significantly, as I will now explain.)
You have slightly misunderstood what the sort algorithm is doing. What it does is compare each letter from the start of each string to see which has a "greater" value. So (taking your first set of data), just before the last set of double backslahes it has a number. The sequence seen is:
1\\1
2\\2
2\\9
3\\3
4\\4
Which is correct. However, what you were looking for was the files to be sorted by the file name, not its full path. E.g.
1\\1
2\\2
3\\3
4\\4
2\\9
But as stated, the strings are sorted character by character from the start so the second result here is impossible. To do the sort of searching you are after you have one option really. Create a list of FileInfo objects and then sort by file name. Hopefully the following code works but it may not be bug free (untested):
string[] fileEntries = Directory.GetFiles(Application.StartupPath + "/TrainedFaces/", "*.bmp", SearchOption.AllDirectories);
List<FileInfo> FileInfos = fileEntries.ToList().ConvertAll(x => new FileInfo(x)).ToList();
FileInfos = FileInfos.OrderBy(x => x.Name).ToList();
foreach (FileInfo AFileInfo in FileInfos)
{
LoadFaces = AFileInfo.Name;
trainingImages.Add(new Image<Gray, byte>(AFileInfo.FullName));
}
Hope this helps,
Ed