Optimizing error-sorting method I just made this sort method. It runs fine and the code looks okay in my eyes.

Is is possible to optimize it so it runs faster?  If it's \$O(n^3)\$ now, it would be interesting changing it to \$O(n^2)\$ or something like that.

Side question: This is \$O(n^3)\$, right (I only like \$O(n^2)\$ and below)?

List&lt;Log&gt; errors = _logHandler.GetErrors(daysBack);
        List&lt;Log&gt; errorsSorted = new List&lt;Log&gt;();
        for (int i = 0; i &lt; errors.Count; i++)
        {
            bool inserted = false;
            for (int j = 0; j &lt; errorsSorted.Count; j++)
            {
                if (errors[i].Date &lt; errorsSorted[j].Date)
                {
                    List&lt;Log&gt; tempList = new List&lt;Log&gt;();
                    tempList.AddRange(errorsSorted.GetRange(j, 
                        errorsSorted.Count - j));

                    errorsSorted[j] = errors[i]; // replace at bigger date index
                    inserted = true;

                    errorsSorted.RemoveRange(j+1, errorsSorted.Count - (j+1));

                    // move all bigger dates one place to the right..
                    foreach (Log log in tempList) 
                    {
                        errorsSorted.Add(log);
                    }
                    break;
                }
            }
            if (!inserted)
            {
                errorsSorted.Add(errors[i]); // No date is bigger, add at the end
            }
        }
You are just sorting by date, correct? I'd use

using System.Linq;
// ....
List&lt;Log&gt; errors = _logHandler.GetErrors(daysBack);
List&lt;Log&gt; errorsSorted = errors.OrderBy(l =&gt; l.Date).ToList();


According to this stackoverflow question, OrderBy uses QuickSort in this case, which usually has a run time of O(n log n).