Here you can find the source of sortAndJoin(List
static String sortAndJoin(List<String> list)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.Collections; import java.util.List; public class Main { static String sortAndJoin(List<String> list) { Collections.sort(list);//from ww w. ja va 2 s. c o m StringBuilder builder = new StringBuilder(10 * list.size()); String sep = ""; for (String name : list) { builder.append(sep); builder.append(name); sep = " "; } return builder.toString(); } }