Created
October 23, 2014 06:42
-
-
Save RyanABailey/2ff9d5cb512ae615d707 to your computer and use it in GitHub Desktop.
c# custom list sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var menuItems = new List<MenuItem>(); | |
| // add items | |
| menuItems.sort(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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