.net - Correct this LINQ instruction syntax -


i list files of directory , sort file extension:

dim files list(of io.fileinfo) = get_files(directory, true, validextensions).orderby(function(x) x.extension).tolist 

how can add in same instruction parameter sort name content this?:

x.name.tolower.contains("word") 

i've tried separate comma (yes, stupid):

dim files list(of io.fileinfo) = get_files(directory, true, validextensions).orderby(function(x) x.extension, x.name.tolower.contains("word")).tolist 
update 

i've tried use @p.s.w.g solution not return desired result.

but if make 2 lists separate desired sort in second list:

 dim files list(of io.fileinfo) = _ get_files(directory, true, validextensions).orderby(function(x) x.extension).tolist  dim files2 list(of io.fileinfo) = _ files.orderby(function(x) x.name.tolower.contains("word")).tolist 

but want improve doing in first list.

use thenby method:

dim files list(of io.fileinfo) = _     get_files(directory, true, validextensions) _         .orderby(function(x) x.extension) _         .thenby(function(x) x.name.tolower.contains("word")) _         .tolist 

update have items not contain "word" in name come first, use this:

dim files list(of io.fileinfo) = _     get_files(directory, true, validextensions) _         .orderby(function(x) x.name.tolower.contains("word")) _         .thenby(function(x) x.extension) _         .tolist 

of course can swap orderby orderbydescending , thenby thenbydescending revers order of single sort key if necessary.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -