/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{

	public static void main (String[] args) throws java.lang.Exception
	{
		String[] array = {"string-a01","string-a20","string-a100","string-b01","string-b20","string-b100","string-c01","string-c20","string-c100"};

        Arrays.sort(array, new Comparator<String>() {
        	int firstTrailingDigit(String s) {
  				int i = s.length();
  				while (i > 0 && Character.isDigit(s.charAt(i - 1))) {
    				--i;	
  				}
  				return i;
			}
			
			@Override public int compare(String a, String b) {
  				int ftdA = firstTrailingDigit(a);
  				int ftdB = firstTrailingDigit(b);

  				// Get the leading strings, and compare.
  				String sA = a.substring(0, ftdA);
  				String sB = b.substring(0, ftdB);
  				int compareStrings = sA.compareTo(sB);
  				if (compareStrings != 0) {
    				// If they're not equal, return the result of the comparison.
    				return compareStrings;
  				}

  				// Get the trailing numbers from the strings, and compare.
  				int iA = Integer.parseInt(a.substring(ftdA));
  				int iB = Integer.parseInt(b.substring(ftdB));
  				return Integer.compare(iA, iB);
			}
        });

        System.out.println(Arrays.toString(array));
	}
}