title: C# Sort Object[] Array within ArrayList?
body: <p>I am not sure how to go about sorting the ArrayList which contains an object Array which has a DateTime object and a String object. I am ultimately trying to sort the ArrayList based on the first object (DateTime) of the array within the ArrayList.</p>
  
  <p>I've tried to search around for sorting but articles didn't seem to go into the level of detail or this particular use-case the application is hitting. I'm not sure if this is the best way to deal with the data either but any help suggestion will certainly be appreciative. </p>
  
  <p>The goal is to read mutliple XML files and combine all the Lap data out of the all the XML files and sort them from oldest to most recent then to create a new XML file with the combined sorted information in it. </p>
  
  <pre><code>ArrayList LapsArrayList = new ArrayList();
  
  ListBox.SelectedObjectCollection SelectedItems = lstSelectedFiles.SelectedItems;
  
  foreach (string Selected in SelectedItems)
  {
      Object[] LapArray = new Object[2];
  
      XmlDocument xDoc = new XmlDocument();
      xDoc.Load(Path + @"\" + Selected);
  
      XmlNodeList Laps = xDoc.GetElementsByTagName("Lap");
  
      foreach (XmlElement Lap in Laps)
      {
          LapArray[0] = DateTime.Parse(Lap.Attributes[0].Value);
          LapArray[1] = Lap.InnerXml.ToString();
          LapsArrayList.Add(LapArray);
      }
  }
  </code></pre>
  
  <p>XML Data Example</p>
  
  <pre><code>&lt;Lap StartTime="2013-06-17T12:27:21Z"&gt;&lt;TotalTimeSeconds&gt;12705.21&lt;/TotalTimeSeconds&gt;&lt;DistanceMeters&gt;91735.562500&lt;/DistanceMeters&gt;&lt;MaximumSpeed&gt;10.839000&lt;/MaximumSpeed&gt;&lt;Calories&gt;3135&lt;/Calories&gt;&lt;AverageHeartRateBpm&gt;&lt;Value&gt;151&lt;/Value&gt;.....&lt;/Lap&gt;
  </code></pre>