Java List Sort stringListSort(List list)

Here you can find the source of stringListSort(List list)

Description

string List Sort

License

Open Source License

Declaration

public static List<String> stringListSort(List<String> list) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static List<String> stringListSort(List<String> list) {
        class ComparatorThis implements Comparator<String> {
            public int compare(String o1, String o2) {
                String s1 = (String) o1;
                String s2 = (String) o2;
                if (s1 == null || s2 == null) {
                    return 0;
                }//from  w ww  . j  a  v a 2 s  .  c om
                return s1.compareTo(s2);
            }
        }
        ;

        Comparator<String> comparator = new ComparatorThis();
        Collections.sort(list, comparator);
        return list;
    }
}

Related

  1. sortStringList(List stringList)
  2. sortStringList(String[] listToSort, String[] priorityList)
  3. sortUniq(List list)
  4. sortUniqueTags(List unsortedTags)
  5. sortVersions(List versions)
  6. subtractSortedLists(List a, List b, Comparator comparator)
  7. toSortedList(Collection in)
  8. toSortedList(Collection collection)
  9. toSortedList(Collection collection)