c# - Reorder a List of string using LINQ -


i have list of string list contains state names. need move few states(ex new york, california etc) appear @ top of list. how can using linq? fyi: list alreday sorted in alphabetical order.

its simple list , few important states needs @ top. no criteria.

the following proof of concept using letters instead of states.

var = new list<string>() {"a","b","c","d","e"}; var top = new list<string>() {"c","d"};  var finallist = top.concat(all.except(top)); 

the idea have full list of states (all) , list of ones want @ top ('top'). take ones @ top , concatenate list of remaining ones create using except method.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -