Skip to content

Instantly share code, notes, and snippets.

@RyanABailey
Created October 23, 2014 06:42
Show Gist options
  • Select an option

  • Save RyanABailey/2ff9d5cb512ae615d707 to your computer and use it in GitHub Desktop.

Select an option

Save RyanABailey/2ff9d5cb512ae615d707 to your computer and use it in GitHub Desktop.
c# custom list sort
var menuItems = new List<MenuItem>();
// add items
menuItems.sort();
public class MenuItem : IComparable<MenuItem>
{
public int MenuID { get; set; }
public int ParentID { get; set; }
public string Title { get; set; }
public string URL { get; set; }
public int SortOrder { get; set; }
public int CompareTo(MenuItem other)
{
return this.SortOrder.CompareTo(other.SortOrder);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment