title: Splitting a list into alphabetic ranges
body: <p>I need to split a list into multiple lists that are grouped according to the first character of a string property. Here's an example.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var makes = new List&lt;VehicleMake&gt;
                          {
                              new VehicleMake {Name = "Acura"},
                              new VehicleMake {Name = "AMG"},
                              new VehicleMake {Name = "Audi"},
                              new VehicleMake {Name = "BMW"},
                              new VehicleMake {Name = "Chevrolet"},
                              new VehicleMake {Name = "Datsun"},
                              new VehicleMake {Name = "Eagle"},
                              new VehicleMake {Name = "Fiat"},
                              new VehicleMake {Name = "Honda"},
                              new VehicleMake {Name = "Infiniti"},
                              new VehicleMake {Name = "Jaguar"}
                          };
  
          var balancedLists = makes.Balance(new List&lt;BalancedListGroup&gt;
                            {
                                new BalancedListGroup { RangeStart = 'A', RangeEnd = 'C'},
                                new BalancedListGroup { RangeStart = 'D', RangeEnd = 'F'},
                                new BalancedListGroup { RangeStart = 'G', RangeEnd = 'J'},
                            });
  
          foreach (var balancedList in balancedLists)
          {
              foreach (var vehicleMake in balancedList)
              {
                  Console.WriteLine(vehicleMake.Name);
              }
              Console.WriteLine("---");
          }
          Console.ReadLine();
      }
  }
  
  public class VehicleMake
  {
      public string Name { get; set; }
  }
  
  public static class VehicleMakeListBalancer
  {
      public static List&lt;List&lt;VehicleMake&gt;&gt; Balance(this List&lt;VehicleMake&gt; list, List&lt;BalancedListGroup&gt; groups)
      {
          var letters =
              new List&lt;string&gt; { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "y", "z" };
          var balancedLists = new List&lt;List&lt;VehicleMake&gt;&gt;();
          foreach (var group in groups)
          {
              var groupList = new List&lt;VehicleMake&gt;();
              for (var i = letters.IndexOf(group.RangeStart.ToString().ToLower()); i &lt;= letters.IndexOf(group.RangeEnd.ToString().ToLower()); i++)
              {
                  groupList.AddRange(list.Where(l =&gt; l.Name.ToLower().StartsWith(letters[i].ToString())).ToList());
              }
              balancedLists.Add(groupList);
          }
  
          return balancedLists;
      }
  }
  
  public class BalancedListGroup
  {
      public char RangeStart { get; set; }
      public char RangeEnd { get; set; }
  }
  </code></pre>
  
  <p>Which outputs:</p>
  
  <pre><code>Acura
  AMG
  Audi
  BMW
  Chevrolet
  ---
  Datsun
  Eagle
  Fiat
  ---
  Honda
  Infiniti
  Jaguar
  ---
  </code></pre>
  
  <p>This algorithm works, but feels very clumsy. Is there a more elegant way to do this?</p>