Package cn.mindit.atom.core.util
Class NaturalComparator
java.lang.Object
cn.mindit.atom.core.util.NaturalComparator
- All Implemented Interfaces:
Comparator<String>
自然排序比较器, 如 aka-2.jpg 应该排在 aka-11.jpg 之前
实现原理: 首先将字符串切分,分为全数字字符串与其他,再各部分一一对应比较,
若皆为全数字字符串,则比较其值,否则按字符比较。
- Since:
- 2023-09-12
- Author:
- Catch
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
NaturalComparator
public NaturalComparator()
-
-
Method Details
-
compare
- Specified by:
comparein interfaceComparator<String>
-