public static void writeListToFileAfterSort(List<String> entries, String resFile, DDLOperationContext context)
      throws IOException {
    Collections.sort(entries);

    StringBuilder sb = new StringBuilder();
    for (String entry : entries) {
      ShowUtils.appendNonNull(sb, entry, true);
    }

    ShowUtils.writeToFile(sb.toString(), resFile, context);
  }
Common utilities for Privilege related ddl operations.
ql/src/java/org/apache/hadoop/hive/ql/ddl/privilege/PrivilegeUtils.java