title: Sorting with IEnumerable - XAML
body: <p>I have a List called VehicleList and an IEnumerable list call FileredVehicleList. I fill the VehicleList with class and their properties and put them in a listbox, When the user switches the option From all to any of the options I want the listbox to show vehicles with only that class of vehicle in it.</p>
  
  <p>So my question is how do I get the VehicleList, sort it, take out only the vehicles the user wants and put it into FilteredVehicleList to display in the listbox?</p>
  
  <p>Code: </p>
  
  <pre><code> public List&lt;Vehicle&gt; VehicleList = new List&lt;Vehicle&gt;();
   public IEnumerable&lt;Vehicle&gt; FilteredVehicleList = new List&lt;Vehicle&gt;();
  
   Vehicle v1 = new Car() { Make = "Ford", Model = "Fiesta", Price = 10000, Year = "1999", Colour = "Red", Mileage = 50000, Description = "Lovely red car, 4 wheel, optional steering wheel.", VehicleType = "Car"};
          VehicleList.Add(v1);
          Vehicle v2 = new Car() { Make = "Ford", Model = "Mondeo", Price = 20000, Year = "2001", Colour = "Green", Mileage = 50000, Description = "Lovely green car, 4 wheel, optional steering wheel.", VehicleType = "Car" };
          VehicleList.Add(v2);
          Vehicle v3 = new Car() { Make = "Ford", Model = "Fiesta", Price = 15000, Year = "2003", Colour = "Silver", Mileage = 50000, Description = "Lovely silver car, 4 wheel, optional steering wheel.", VehicleType = "Car" };
          VehicleList.Add(v3);
          Vehicle v4 = new Car() { Make = "Opel", Model = "Astra", Price = 25000, Year = "2002", Colour = "Silver", Mileage = 50000, Description = "Lovely silver car, 4 wheel, optional steering wheel.", VehicleType = "Car" };
          VehicleList.Add(v4);
          Vehicle v5 = new Bike() { Make = "Kawasaki", Model = "ZX", Price = 30000, Year = "2008", Colour = "Black", Mileage = 25000, Description = "Lovely black bike, 2 wheel, no optional steering wheel.", VehicleType = "Bike" };
          VehicleList.Add(v5);
  
  string[] filterBox = { "All", "Price", "Mileage", "Make" };
          comboBox_sortCars.ItemsSource = filterBox;
          comboBox_sortCars.SelectedIndex = 0;
  
          FilteredVehicleList = VehicleList;
  
  
      private void comboBox_sortCars_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          var output = listbox_cars.ItemsSource = "";
          var filter;
          string sortBy = comboBox_sortCars.SelectedValue.ToString();
  
          switch (sortBy)
          {
              case "Make":
                  filter = FilteredVehicleList.VehicleType.OrderBy(i =&gt; i.Make)
  
                  break;
          }
  </code></pre>