Sorting string like windows file name sorting
807591Apr 24 2008 — edited Apr 25 2008Hi everybody, I have a simple question.
I was trying to sort some file name in java
Let say we have a list of string which are :
1.txt
a.txt
2.txt
11.txt
a(1).txt
a(11).txt
a(2).txt
If i convert those strings as file names, and sort it by file name in the windows explorer the result is
1.txt
2.txt
11.txt
a(1).txt
a(2).txt
a(11).txt
a.txt
But if i enter those strings into an Arraylist and use Arrays.sort or Collections.sort, the result is
1.txt
11.txt
2.txt
a(1).txt
a(11).txt
a(2).txt
a.txt
Is there a way to achieve the string sort similar to windows rather than aplhabetically like the default sort of Arrays/Collection.
I have done some searching but only found problem regarding to different language character sorting which can be achieved using Collator but this was not my case. Has anybody encounter this issue ?
Any help is greatly appreciated
regards
Hendra Effendi