title: Sorting Custom DateTime C#
body: <p>I need help sorting custom DateTime in listbox in descending order.</p>
  
  <p>My code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace WindowsFormsApplication6
  {
      public partial class Form2 : Form
      {
  
          public Form2()
          {
              InitializeComponent();
              dateTimePicker1.Format = DateTimePickerFormat.Custom;
              dateTimePicker1.CustomFormat = "dd/mm/yyyy  HH:mm";
  
  
  
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              listBox1.Items.Add(textBox1.Text + ", " + Convert.ToDateTime(this.dateTimePicker1.Value).ToString("dd/mm/yyyy HH:mm"));
          }
  
          private void button2_Click(object sender, EventArgs e)
          {
              listBox1.Items.Remove(listBox1.SelectedItem);
          }
  
          private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
          {
  
              dateTimePicker1.CustomFormat = "dd/mm/yyyy  HH:mm";   
          }
      }
  }
  </code></pre>
  
  <p>I add the text from textBox1 and date and time from DateTimePicker1, I would like it to sort automatically depending on the time.</p>
  
  <p>Thanks !</p>