Java List Sort sortAndFormat(List stringList)

Here you can find the source of sortAndFormat(List stringList)

Description

sort And Format

License

Creative Commons License

Declaration

public static String sortAndFormat(List<String> stringList) 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

import java.util.Arrays;

import java.util.List;

public class Main {
    public static String sortAndFormat(List<String> stringList) {
        if (stringList == null) {
            return "";
        }//  w w  w . ja va2s.c om
        String[] stringArray = stringList.toArray(new String[0]);
        Arrays.sort(stringArray);

        StringBuilder buffer = new StringBuilder();
        for (int i = 0; i < stringArray.length; i++) {
            if (i > 0) {
                buffer.append(";");
            }
            buffer.append(stringArray[i]);
        }

        return buffer.toString();
    }
}

Related

  1. sort(List list, Comparator comparator)
  2. sort(List list, Comparator comparator, String sort, boolean sortOrder)
  3. sort(List objs, Comparator cp)
  4. sort(Set list, Comparator comparator)
  5. sort(String prefix, int[] a, List list)
  6. sortAndReturn(final List list)
  7. sortBy(List> list, final Map orderBy)
  8. sortByByteDeux(List symbolAL, int delimiter)
  9. sortByClosestMatch(final List strings, final String toMatch)