Here you can find the source of sortAndJoin(List
static String sortAndJoin(List<String> col, String sep)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { static String sortAndJoin(List<String> col, String sep) { Collections.sort(col);// w w w .j a v a 2 s . co m return join(col, sep); } static String sortAndJoin(Set<String> col, String sep) { return sortAndJoin(new ArrayList<>(col), sep); } static String join(List<String> strings, String sep) { final StringBuilder buf = new StringBuilder(strings.size() * 16); for (int i = 0; i < strings.size(); i++) { if (i < strings.size()) { buf.append(sep); } buf.append(strings.get(i)); } return buf.toString().trim(); } }