2

I have the following list of strings, I would like to sort them just as the same way "sort by name" in windows

Dim arrayInput As List(Of String) = New List(Of String)
    arrayInput.Add("CE4-B1-D1.csv")
    arrayInput.Add("CE4-B1-D1-1.csv")
    arrayInput.Add("CE4-B1-D1-3.csv")
    arrayInput.Add("CE4-B1-D1-2.csv")
    arrayInput.Add("CE4-B1-D2.csv")
    arrayInput.Add("CE4-B1-D2-1.csv")
    arrayInput.Add("CE4-B1-D2-2.csv")
    arrayInput.Add("CE4-B1-D11.csv")
    arrayInput.Add("CE4-B1-D11-1.csv")
    arrayInput.Add("CE4-B1-D7.csv")

If I use the arrayInput.Sort(), the result would be

    CE4-B1-D1.csv   
    CE4-B1-D11.csv  
    CE4-B1-D1-1.csv
    CE4-B1-D11-1.csv
    CE4-B1-D1-2.csv
    CE4-B1-D1-3.csv 
    CE4-B1-D2.csv   
    CE4-B1-D2-1.csv 
    CE4-B1-D2-2.csv 
    CE4-B1-D7.csv

But what I want is something like this:

    CE4-B1-D1.csv       
    CE4-B1-D1-1.csv
    CE4-B1-D1-2.csv
    CE4-B1-D1-3.csv 
    CE4-B1-D2.csv   
    CE4-B1-D2-1.csv 
    CE4-B1-D2-2.csv 
    CE4-B1-D7.csv
    CE4-B1-D11.csv
    CE4-B1-D11-1.csv
2342G456DI8
  • 1,819
  • 3
  • 16
  • 29
  • The windows-way with `StrCmpLogicalW`: http://stackoverflow.com/questions/248603/natural-sort-order-in-c-sharp – Tim Schmelter Mar 03 '14 at 08:53
  • without: [Sorting arrays numerically and alphabetically(like Windows Explorer) without using StrCmpLogicalW or shlwapi.dll - ASP.NET VB](http://stackoverflow.com/questions/4165662/sorting-arrays-numerically-and-alphabeticallylike-windows-explorer-without-usi) – Tim Schmelter Mar 03 '14 at 08:54

0 Answers0