We developed a web part showing the folders hierarchy using tree view control. However the folders were not getting displayed in the tree view node in the order they are visible inside the document library i.e. sorted on name.
Creating a tree view
So finally used the following code to sort the folders
List<SPFolder> folderList = new List<SPFolder>();
foreach (SPFolder myFolder in folder.SubFolders){
folderList.Add(myFolder);
}
folderList.Sort(delegate(SPFolder p1, SPFolder p2) { return p1.Name.CompareTo(p2.Name); });
For more information on sorting
http://www.developerfusion.com/code/5513/sorting-and-searching-using-c-lists/
Bye..


[...] best I got from Google was this post, but I think it can be done even sleeker. First create a temporary generic list, then sort it using [...]
[...] Sort SPFolder in SharePoint [...]
Thanks! I had the exact same issue……