<gouthampradhan>hashing_CustomSortString_1.java
public String customSortString(String S, String T) {
    Map<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < T.length(); i++) {
      if (!map.containsKey(T.charAt(i))) {
        map.put(T.charAt(i), 1);
      } else {
        map.put(T.charAt(i), map.get(T.charAt(i)) + 1);
      }
    }
    StringBuilder result = new StringBuilder();
    for (char c : S.toCharArray()) {
      if (map.containsKey(c)) {
        int count = map.remove(c);
        for (int i = 0; i < count; i++) {
          result.append(c);
        }
      }
    }
    for (char c : map.keySet()) {
      int count = map.get(c);
      for (int i = 0; i < count; i++) {
        result.append(c);
      }
    }
    return result.toString();
  }
public String var_0 ( String var_2 , String var_3 ) {
  Map < Character , Integer > var_8 = new HashMap < > ( ) ;
  for ( int var_10 = 0 ;
  var_10 < var_3 . length ( ) ;
  var_10 ++ ) {
    if ( ! var_8 . containsKey ( var_3 . charAt ( var_10 ) ) ) {
      var_8 . put ( var_3 . charAt ( var_10 ) , 1 ) ;
    }
    else {
      var_8 . put ( var_3 . charAt ( var_10 ) , var_8 . get ( var_3 . charAt ( var_10 ) ) + 1 ) ;
    }
  }
  StringBuilder var_18 = new StringBuilder ( ) ;
  for ( char var_20 : var_2 . toCharArray ( ) ) {
    if ( var_8 . containsKey ( var_20 ) ) {
      int var_22 = var_8 . remove ( var_20 ) ;
      for ( int var_10 = 0 ;
      var_10 < var_22 ;
      var_10 ++ ) {
        var_18 . append ( var_20 ) ;
      }
    }
  }
  for ( char var_20 : var_8 . keySet ( ) ) {
    int var_22 = var_8 . get ( var_20 ) ;
    for ( int var_10 = 0 ;
    var_10 < var_22 ;
    var_10 ++ ) {
      var_18 . append ( var_20 ) ;
    }
  }
  return var_18 . toString ( ) ;
}
