c# - Sorting Using Linq Where list contains alphabets and Numerics -
imagine have string list or custom list in 1 of string field contains following data
a 5 d 3 1 b 2 4 c
how sort list output
a b c d 1 2 3 4 5
where orderby gives following answer
1 2 3 4 5 b c d
much simpler method:
string inputstring = "a5d31b24c"; var output = inputstring.orderby(x => char.isdigit(x)).thenby(x=>x).tolist();   the first orderby sort list : abcd53124, because orderby evaluate boolean values in order of false true. following thenby give expected result abcd12345
Comments
Post a Comment