private String sortInputOutput(String source) {
    Matcher matcher = ENTITYLIST_PATTERN.matcher(source);
    while(matcher.find()) {
      List<String> lines = Arrays.asList(matcher.group(1).split("\n"));
      Collections.sort(lines);
      source = source.replaceAll(matcher.group(1), String.join("\n", lines) + "\n");
    }
    return source;
  }
The PREHOOK/POSTHOOK Input/Output lists should be sorted again after reverting the database
name in those strings to match the original Cli output.
@param source The original query output
@return The query output where the input/output list are alphabetically ordered
itests/util/src/main/java/org/apache/hive/beeline/QFile.java