Explorer not sorting correctly

Windows 7 Explorer is not sorting files correctly.  I have sorted them by Name ascending and also done a DIR command,  Sort order is different.  Any ideas?
FileSort.png
rogerfg7Asked:
Who is Participating?
 
Dan CraciunConnect With a Mentor IT ConsultantCommented:
Use this function: StrCmpLogicalW(file1.Path, file2.Path)
http://msdn.microsoft.com/en-us/library/bb759947.aspx
0
 
Dan CraciunConnect With a Mentor IT ConsultantCommented:
Because the first chars are numbers, it sorts correctly:
002
17
380
961
2597
3943
0
 
comfortjeaniusConnect With a Mentor Commented:
Windows sort numbers before alphabets; plus most record management systems perform this action as well.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
rogerfg7Author Commented:
Many thanks for your observation, I never thought of that.

But I want it to sort alphabetically (as per DOS) not numerically. MS too clever sometimes.

Does it also sort Month names in chronological order?
0
 
comfortjeaniusCommented:
You can use the "Date Modified" or you the advance filter by clicking the drop down arrow.Search Features
0
 
Dan CraciunIT ConsultantCommented:
No, it won't put March before December.
0
 
rogerfg7Author Commented:
What I need to do now is modify my VS 2005 code in my application to sort them in the same order as Windows

I am using

file1.FilePath.CompareTo(file2.FilePath) in the IComparer Compare method.

Are there any inbuilt compare routines that act the same as Windows sort or do I write my own?

I guess this might be another post as it is now extending the topic.
0
 
rogerfg7Author Commented:
Just done an Internet search on this very topic and it seems the answer is 'write your own'.

Many thanks guys.  It's always the obvious that you miss!!
0
 
Dan CraciunIT ConsultantCommented:
Why write your own???
StrCmpLogicalW is used by Windows Explorer to sort files. You can't get closer than that :)
0
 
rogerfg7Author Commented:
There seems to be no equivalent available in .Net managed code

stackoverflow.com/questions/8793856/net-equivalent-of-strcmplogicalw
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.