c# - Keeping the item named 'other' at the bottom of my ordered list -
c# - Keeping the item named 'other' at the bottom of my ordered list -
i have list of selectlistitems this:
list<selectlistitem> test = new list<selectlistitem> { new selectlistitem { text="aaa", value ="1"}, new selectlistitem { text="ttt", value="2"}, new selectlistitem { text="bbb", value = "3"}, new selectlistitem { text="other", value = "4"} }.orderby(x => x.text).tolist(); this above code homecoming ordered list this:
aaa bbb other ttti order list maintain item named 'other' @ bottom of list.
how possible?
maybe work
list<selectlistitem> test = new list<selectlistitem> { new selectlistitem { text="aaa", value ="1"}, new selectlistitem { text="ttt", value="2"}, new selectlistitem { text="bbb", value = "3"}, new selectlistitem { text="other", value = "4"} }.orderby(x => x.text == "other").thenby(x => x.text).tolist(); c# asp.net asp.net-mvc
Comments
Post a Comment