Example usage for java.util Collections sort

List of usage examples for java.util Collections sort

Introduction

In this page you can find the example usage for java.util Collections sort.

Prototype

@SuppressWarnings("unchecked")
public static <T extends Comparable<? super T>> void sort(List<T> list) 

Source Link

Document

Sorts the specified list into ascending order, according to the Comparable natural ordering of its elements.

Usage

From source file:co.com.soinsoftware.altablero.controller.TimeController.java

public List<TimeBO> findAll() throws IOException {
    final Set<TimeBO> timeSet = timeBLL.findAll();
    final List<TimeBO> timeList = (timeSet != null) ? new ArrayList<>(timeSet) : new ArrayList<>();
    Collections.sort(timeList);
    return timeList;
}

From source file:co.com.soinsoftware.altablero.controller.GradeController.java

public List<GradeBO> findAll() throws IOException {
    final Set<GradeBO> gradeSet = gradeBLL.findAll();
    final List<GradeBO> gradeList = (gradeSet != null) ? new ArrayList<>(gradeSet) : new ArrayList<>();
    Collections.sort(gradeList);
    return gradeList;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <E> E[] toArray(Collection<?> collection, Class<E> elementType, boolean sort) {
    if (collection == null || collection.isEmpty())
        return null;
    ArrayList arraylist = new ArrayList(collection);
    if (sort) {/*from  www .j  a va2 s. c  o m*/
        Collections.sort(arraylist);
    }

    E[] array = (E[]) Array.newInstance(elementType, arraylist.size());
    arraylist.toArray(array);
    return array;
}

From source file:co.com.soinsoftware.altablero.controller.PeriodController.java

public List<PeriodBO> findAll(final int idSchool) throws IOException {
    final Set<PeriodBO> periodSet = this.bll.findAll(idSchool);
    final List<PeriodBO> periodList = (periodSet != null) ? new ArrayList<>(periodSet) : new ArrayList<>();
    Collections.sort(periodList);
    return periodList;
}

From source file:com.tilab.ca.sse.core.util.SSEUtils.java

public static Map sortIntegersMap(Map passedMap) {
    LOG.debug("[sortHashMapIntegers] - BEGIN");
    List mapKeys = new ArrayList(passedMap.keySet());
    List mapValues = new ArrayList(passedMap.values());
    Collections.sort(mapValues);
    Collections.reverse(mapValues);
    Collections.sort(mapKeys);//from  ww w .  j  av  a2s .com
    Map sortedMap = new LinkedHashMap();
    Iterator valueIt = mapValues.iterator();
    while (valueIt.hasNext()) {
        Object val = valueIt.next();
        Iterator keyIt = mapKeys.iterator();
        while (keyIt.hasNext()) {
            Object key = keyIt.next();
            String comp1 = passedMap.get(key).toString();
            String comp2 = val.toString();
            if (comp1.equals(comp2)) {
                passedMap.remove(key);
                mapKeys.remove(key);
                sortedMap.put((Integer) key, (Integer) val);
                break;
            }
        }
    }
    LOG.debug("[sortHashMapIntegers] - END");
    return sortedMap;
}

From source file:co.com.soinsoftware.altablero.controller.SubjectController.java

public List<SubjectBO> findExcludingClass(final int idClassRoom) throws IOException {
    final Set<SubjectBO> subjectSet = this.subjectBLL.findExcludingClass(idClassRoom);
    final List<SubjectBO> subjectList = (subjectSet != null) ? new ArrayList<>(subjectSet) : new ArrayList<>();
    Collections.sort(subjectList);
    return subjectList;
}

From source file:com.eyem.services.PostService.java

public List<Post> findPublicPost() {
    List<Post> res = postRepository.findPublicPost();

    if (res.isEmpty() || res.size() <= 0) {
        return null;
    } else {//from w w w . j  a  va 2  s.  com
        Collections.sort(res);
        return res;
    }
}

From source file:com.github.stagirs.lingvo.model.Form.java

public Form(List<Attr> attrs) {
    this.attrs = attrs;
    Collections.sort(this.attrs);
}

From source file:de.viaboxx.nlstools.model.MBEntry.java

public void sort() {
    if (texts != null)
        Collections.sort(texts);
}

From source file:com.technofovea.packbsp.packaging.BspZipController.java

public static void writePackingList(Map<String, File> packItems, Writer dest) throws IOException {
    final String newline = "\r\n";
    List<String> keys = new ArrayList<String>();
    keys.addAll(packItems.keySet());/*w  ww . j a v  a 2 s. com*/
    Collections.sort(keys);
    for (String inner : keys) {
        File outer = packItems.get(inner);

        dest.write(inner);
        dest.write(newline);
        dest.write(outer.getAbsolutePath());
        dest.write(newline);

    }
}