c# - How to order by value enumeration statuses? -


i have foreach , how can order last item on first palce , others stay are?

  foreach (statuses val in enum.getvalues(typeof(statuses)))     {        status.add(new statusmodel()           {              value = (string)val.tostring(),              transkey = val.tostring()           });     } 

you can use dirty trick:

var ordered = status     .orderbydescending(s => s.transkey == "valueyouwantatthetop"); 

probably more efficient option:

var tomovetotop = status.first(s => s.transkey == "valueyouwantatthetop"); status.remove(tomovetotop); status.insert(0, tomovetotop); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -