I have read questions related to sorting an array of objects by property, but I have a special case where I need the aditional StringComparer.Ordinal
object to perform a custom sort.
I have a DirectoryInfo[]
array where I need the subdirectories to be sorted by their FullName property but I need the sorting order of the numbers contained in the paths to be:
1 - 2 - 4 - 10 - 14 - 25
instead of
1 - 10 - 14 - 2 - 25 - 4
(I have paths such as c:\Folder\Subfolder\1
, c:\Folder\Subfolder\2
...)
I think this would be acomplished with: Array.Sort(paths, StringComparer.Ordinal)
if my array was an array of strings.
How can I acomplish this if my array is an array of DirectoryInfo[]
? I would like to avoid extending DirectoryInfo by creating a new class.