sort String List - Java java.lang

Java examples for java.lang:String Sort

Description

sort String List

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.Collections;

import java.util.List;
import java.util.Set;

public class Main {
    public static List<String> sortString(Set<String> lists) {
        if (lists == null) {
            return null;
        } else {//from ww  w  .  j a v a2s  .c  om
            List<String> result = new ArrayList<String>();
            for (String domain : lists) {
                result.add(domain);
            }
            Collections.sort(result);
            return result;
        }
    }

    public static List<String> sort(List<String> lists) {
        Collections.sort(lists);
        return lists;
    }

    public static List<String> sort(Set<String> lists) {
        if (lists == null) {
            return null;
        } else {
            List<String> result = new ArrayList<String>();
            for (String temp : lists) {
                result.add(temp);
            }
            return sort(result);
        }
    }
}

Related Tutorials