title: Lexicographically sort C#
body: <p>I have this code for sorting strings:</p>
  
  <pre><code> class Program
  {
      static void Main()
      {
  
          int x = Convert.ToInt32(Console.ReadLine());
          List&lt;string&gt; sampleList = new List&lt;string&gt;();
  
          for (int i=0; i&lt;x; i++)
          {
              string word = Console.ReadLine();
              sampleList.Add(word);
          }
  
  
          foreach (string s in SortByLength(sampleList))
          {
              Console.Write(s);
          }
          Console.ReadLine();
      }
  
      static IEnumerable&lt;string&gt; SortByLength(IEnumerable&lt;string&gt; e)
      {
          // Use LINQ to sort the array received and return a copy.
          var sorted = from s in e
                       orderby s.Length descending
                       select s;
          return sorted;
      }
  }
  </code></pre>
  
  <p>This code sorting strings by length, how can I do that by length and lexicographically ?</p>
  
  <p>Example </p>
  
  <pre><code>//Input
  4
  abba
  abacaba
  bcd
  er
  
  //Output
  abacabaabbabcder
  </code></pre>
  
  <p>In this case work fine, but when I have </p>
  
  <pre><code>//Input
  5
  abba
  ebacaba
  bcd
  er
  abacaba
  
  //Output
  ebacabaabacabaabbabcder
  </code></pre>
  
  <p>My first string is ebacaba which is wrong.</p>