c# - Sorting IEnumerable<SelectListItem> by Text field -


i don't know if i'm doing wrong here, can't sorted list when using:

public static ienumerable<selectlistitem> toselectlist<tenumerable>(     ienumerable<tenumerable> enumerable,     func<tenumerable, int> value,     func<tenumerable, string> text) {     return enumerable.select(         item => new selectlistitem         {             value = value(item).tostring(cultureinfo.invariantculture),             text = text(item)         }).orderby(sli => sli.text); } 

but when using following, list ordered 'value' field without issues:

    return enumerable.select(         item => new selectlistitem         {             value = value(item).tostring(cultureinfo.invariantculture),             text = text(item)         }).orderby(sli => sli.value); 

i list sorted 'text' field. appreciated.


Comments