我有一个包含AA0 AA5 BB2 BB9 AA1 BB13 AA7 AA2不按顺序的字符串列表.我想要的是两个单独的类别,如AA0 AA1 AA2 AA5 AA7 BB2 BB9 BB13我可以这样做?
我试图myList.stream().sorted(mySorter).foreach(...);在那里mySorter象下面这样:
private final Comparator<String> mySorter= ( o1, o2 ) -> {
try
{
final int first = Integer.parseInt( o1.substring( 2, o1.length() ) );
final int second = Integer.parseInt( o2.substring( 2, o2.length() ) );
System.out.println( o1 + " -> " + first + " " + o2 + " -> " + second );
if ( o1.contains( "AA" …Run Code Online (Sandbox Code Playgroud)