private static void sortMethods(List<Method> methods) {
    Collections.sort( methods, new Comparator<Method>(){

      @Override
      public int compare(Method m1, Method m2) {
        int result = m1.getName().compareTo(m2.getName());
        if (result != 0)
          return result;
        Type[] types1 = m1.getGenericParameterTypes();
        Type[] types2 = m2.getGenericParameterTypes();
        for (int i = 0; i < types1.length && i < types2.length; i++) {
          String type1 = ObjectInspectorUtils.getTypeNameFromJavaClass(types1[i]);
          String type2 = ObjectInspectorUtils.getTypeNameFromJavaClass(types2[i]);
          if ((result = type1.compareTo(type2)) != 0)
            return result;
        }
        return types1.length - types2.length;
      }

    });
  }
Constructor.

@param funcClass
         The UDF or UDAF class.
@param argTypeInfos
         The list of argument types that lead to an ambiguity.
@param methods
         All potential matches.
udf/src/java/org/apache/hadoop/hive/ql/exec/UDFArgumentException.java