Q:

Sorting A Custom List C#

I have a list of windows but it is not in the order I want them. I'm able to get the windows into string from the title - they are being put into a list of windows. I want to sort this list in a specific order with Estimate 1st, Control Center 2nd, and Login 3rd. This is the order I desire. I have know idea on how to go about it but I want to sort it before it goes into the foreach loop. 
    private void CloseMainWindows(IEnumerable<Window> Windows)
    {
        var winList = Windows.ToList();

        winList.Sort()//This is where I want to sort the list. 

        foreach (Window window in winList)
        {
            if (window.Title.Contains("Estimate"))
            {
                Estimate.closeEstimateWindow();
            }
            if (window.Title.Contains("Control Center"))
            {
                ContorlCenter.CloseContorlCenter();
            }
            if (window.Title.Contains("Login"))
            {
                login.ClickCanel();
            }
        } 
    }

A:

One way would be to have a lookup function:
int GetTitleIndex(string s)
{
    if (s.Contains("Estimate")) return 0;
    if (s.Contains("Control Center")) return 1;
    if (s.Contains("Login")) return 2;
}

Then, to sort, you lookup the indexes:
winList.Sort((x, y) => GetTitleIndex(x).CompareTo(GetTitleIndex(y)));

Alternatively, you could create the list directly using LINQ's OrderBy:
var winList = Windows.OrderBy(GetTitleIndex).ToList();

And in fact in your case you don't even need the intermediate list:
foreach (var window in Windows.OrderBy(GetTitleIndex))
{
    ...
}

