.net - Issue trying to ordering using LINQ -
i have directory files named "artist [style] number.ext"
an example:
atomix [dubstep] 01.avi atomix [rock] 02.wmv atomix [rock] 03.avi lacuna [rock] 01.mp4 lacuna [rock] 02.avi
i want use linq list files group them artists, in ordering want include 1 "[style]" , sort each artist file extension, example have included "[rock]" style:
atomix [rock] 03.avi atomix [rock] 02.wmv lacuna [rock] 02.avi lacuna [rock] 01.mp4
"a" goes first "l" , "avi" goes first "wmv", that's desired result when trying ordering kind of sort:
atomix [rock] 03.avi lacuna [rock] 02.avi lacuna [rock] 01.mp4 atomix [rock] 02.wmv
the artists mixed extensions sorted, "avi" goes first "mp4" when sorting "a" of "atomix" goes first "l" of "lacuna", don't know how correct this.
this instruction i'm using filenames i've said before:
dim videos list(of io.fileinfo) = _ get_files(directory, true, validextensions) _ .orderby(function(x) x.extension) _ .where(function(x) x.name.tolower.contains("[rock]")) _ .tolist
ps: i've tried toggle order of methods same result.
update:
i've tried use @jyparask solution still need modification extensions ordered, get:
aa [style] 04.mp4 ab [style] 01.wmv ab [style] 03.wmv ab [style] 05.mp4 ab [style] 05.wmv ab [style] 06.mp4 ab [style] 07.mp4 ab [style] 09999999999964.mp4 ac [style] 166333226.mp4 ac [style] 333133333333313313322.mp4 ac [style] 44.mp4 ac [style] 6049.wmv
and code i'm using:
dim videos list(of io.fileinfo) = _ get_files(directory, true, validextensions) _ .where(function(x) x.name.tolower.contains("[word]")) _ .orderby(function(x) x.name) _ .thenby(function(x) x.extension) _ .tolist()
you must first orderby artist , use thenby passing extension.
dim videos list(of io.fileinfo) = _ get_files(directory, true, validextensions) _ .orderby(function(x) x.name.substring(0,x.name.indexof("["))) _ .thenby(function(x) x.extension) _ .where(function(x) x.name.tolower.contains("[rock]")) _ .tolist
Comments
Post a Comment