public class AlphaNumericComparator<T> extends Object implements Comparator<T>
Function
. That value
will be compared in a human readable fashion by trying to parse numbers that appear in
the keys as integers and compare those, too.Heavily influenced by https://codereview.stackexchange.com/questions/37192/number-aware-string-sorting-with-comparator
Constructor and Description |
---|
AlphaNumericComparator(Function<T,String> converter)
Constructs a comparator with a converter function
|
Modifier and Type | Method and Description |
---|---|
int |
compare(T o1,
T o2) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public AlphaNumericComparator(Function<T,String> converter)
converter
- that generates a String value from the arguments given to Comparator.compare(Object, Object)
public int compare(T o1, T o2)
compare
in interface Comparator<T>
Copyright © 1998-2022 Apache Software Foundation. All Rights Reserved.