Hello All,
I am having a small piece of code in my project that retrieves file names from a directory applying filename filter. Well i am happening to get them fine in sorted order. But when i implement that program in other machine it happens that all the file names are in unsorted order. I applied several sorting techniques Collator, SortedSet etc. no luck</stro> *Any could help me on this. By the way my development machine has JDK 1.6 while implementing system has only JRE1.5 which comes embedded with jBase. Consider i have nothing to do with jBase thats another team's project.
The sort order is determined by the underlying file system, and that does not guarantee a sort order. Often it uses file creation date.
Your code is... impressive, but what's wrong with a simple Arrays.sort() call using a custom (or preexisting) comparator? For instance, to sort on name ignoring the case:
Well as i said i even tried Arrays.sort also with String.CASE_INSENSITIVE_ORDER no luck. Well you are right i suppose because the development machine has FAT32 and the implementing machine has NTFS. Oh no whats next.
I don't understand - if you use Rob's approach its Strings you are sorting, not Files. Strings are not going to be impacted by the underlying file system.
Not if your sort is alphabetic, which it is. Normally, AAB comes before AB, simmilaraly 112 comes before 12. If you want it to sort differently you'll need to implement this in a custom Comparator.