You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Emmanuel Bourg <eb...@apache.org> on 2005/01/06 02:38:10 UTC
Re: [collections] FilenameComparator
Interesting, your implementation is a bit more sophisticated, but at
least it proves that this kind of comparator is a common concern.
Would the Collections folks reconsider their decision and accept such a
comparator due to "popular" demand ? :) I'm attaching my implementation.
Emmanuel Bourg
Henri Yandell wrote:
> I offered one of those to Collections a while back but it was turned
> down as it chose one specific way to do the ordering:
>
> http://www.osjava.org/genjava/multiproject/gj-core/xref/com/generationjava/compare/NumericStringComparator.html
>
> For your submission, I think as a comparator of Strings to Collections
> makes the most sense as it deals with java.util.Comparator and Lang
> doesn't.
>
> Anything in my class is up for grabs if you want any of it :)
>
> Hen
>
> On Wed, 05 Jan 2005 01:13:13 +0100, Emmanuel Bourg <eb...@apache.org> wrote:
>
>>Hi all, I have developped a File comparator to sort properly the files
>>with a number in the name. For example, instead of sorting with the
>>lexicographic order :
>>
>>foo1.txt < foo10.txt < foo2.txt
>>
>>it compares the numbers when the files share the same prefix and returns
>>this order :
>>
>>foo1.txt < foo2.txt < foo10.txt
>>
>>This is how the "Sort by name" works in the Windows XP file explorer.
>>Since it's quite low level I think it could be included in a commons
>>project, but I'm not sure where:
>>
>>- in [io] as a getComparator() method in FileUtils or as a
>>FilenameComparator class ?
>>
>>- in [lang] as a String comparator ?
>>
>>- nowhere because this was already implemented in another well known
>>project and I wasted my time reinventing the wheel ;)
>>
>>Emmanuel Bourg