Windows sorting order in JAVA and python -


i have below files in windows xp. after sorting according name orders in below manner.

test_1a.play test_1aa.play test_1aaa.play test_1ab.play test_1ac.play test-_1aaaa.play 

if read these files in java , collections.sort(listoffiles) or python , listoffiles.sort() below order

test-_1aaaa.play test_1aa.play test_1ab.play test_1ac.play test_1a.play test_1aaa.play 

in gui need display files in order windows ordering. folders above names sorted default sorting mechanism. files disordered. searching compare method used in windows use java , python. can 1 me comparator solve this

try :

    collections.sort(files,new comparator<file>()     {         collator mycollator = collator.getinstance();         @override         public int compare(file o1, file o2)         {             return mycollator.compare(o1.getname(),o2.getname());         }     }); 

the difference because windows case insensitive. if @ doc of collator says :

the collator class performs locale-sensitive string comparison.

you have comparator that. if list not list of files list of strings easier since compartor exists : http://docs.oracle.com/javase/6/docs/api/java/lang/string.html#case_insensitive_order


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -