Sort files by name in Java differs from Windows Explorer
- by Martyn Hopkins
I have a simple Java program which reads a file directory and outputs a file list.
I sort the files by name:
String [] files = dirlist.list();
files = sort(files);
My problem is that it sorts by name in a different way than Windows Explorer does.
For instance if I have these files: abc1.doc, abc12.doc, abc2.doc.
Java will sort like this:
abc1.doc
abc12.doc
abc2.doc
When I open the folder in Explorer, my files are sorted like this:
abc1.doc
abc2.doc
abc12.doc
How can I make Java sorts my files like in Windows Explorer?
Is this a Windows trick?