Java implementation of Alpha-numeric comparator
xueming.shen at oracle.com
Tue Dec 16 19:04:02 UTC 2014
On 12/16/2014 06:58 AM, roger riggs wrote:
> Hi Ivan,
> In which package/class do you propose to add the API to get the comparator?
> In java.time, comparators are returned from static methods in an interface.
> This allows lambda to be used for the implementation.
> For example, ChronoZonedDateTime.timeLineOrder <https://docs.oracle.com/javase/8/docs/api/java/time/chrono/ChronoZonedDateTime.html#timeLineOrder-->()
> For example a static method could be added to CharSequence:
> public static int Comparator<CharSequence> alphaNumericComparator() ...
> In use it would be CharSequence.alphaNumericComparator().compare("012", "234");
This is more like a special case of j.t.Collator. I'm not sure it's a good idea to put this "special"
comparator into CharSequence, without careful planning. I will assume there are more useful
utility comparators people would like to see here. To use the original example, while the
it's good to have this comparator to compare "jdk 10" and "jdk9", how about "jdk-10" and
"jdk 9"? Yes, it is more like a collator:-)
More information about the core-libs-dev