Java Utililty Methods List Sort

List of utility methods to do List Sort

Description

The list of methods to do List Sort are organized into topic(s).

Method

ListsortListEntry(List firstList, List secondList)
sort List Entry
List entrys = new ArrayList();
if (firstList != null && firstList.size() > 0) {
    for (int i = 0; i < firstList.size(); i++) {
        entrys.add(i, firstList.get(i));
    if (secondList != null && secondList.size() > 0) {
        for (int j = firstList.size(); j < firstList.size() + secondList.size(); j++) {
            entrys.add(j, secondList.get(j - firstList.size()));
...
voidsortListOfDoublesAndRemoveDuplicates(List items, double tolerance, double toleranceSmallNumbers)
Sort (in place this list of doubles and remove duplicate values (where 'duplicate(a,b)' is 'not diffDoubles(a,b).'
Collections.sort(items);
Double prev = null;
for (Iterator<Double> iter = items.iterator(); iter.hasNext();) {
    Double d = iter.next();
    if (prev == null || diffDoubles(prev, d, tolerance, toleranceSmallNumbers)) {
        prev = d;
    } else {
        iter.remove();
...
ListsortListStingArrayByFirstDes(List list)
sort List Sting Array By First Des
Comparator<String[]> com = new Comparator<String[]>() {
    public int compare(String[] o1, String[] o2) {
        double num1 = Double.valueOf(o1[0] == null ? "0" : o1[0]);
        double num2 = Double.valueOf(o2[0] == null ? "0" : o2[0]);
        if (num2 < num1) {
            return 1;
        } else if (num2 > num1) {
            return -1;
...
voidsortLocales(final List locales)
Sort the Locales alphabetically.
Collections.sort(locales, LOCALE_COMPERATOR);
ListsortLongSeqList(List firstList, List secondList)
sort Long Seq List
List<Long> entry = new ArrayList<Long>();
if (firstList != null && firstList.size() > 0) {
    if (secondList != null && secondList.size() > 0) {
        int seq = 0;
        for (int i = 0; i < firstList.size(); i++) {
            for (int j = 0; j < secondList.size(); j++) {
                if (secondList.get(j) == firstList.get(i).longValue()) {
                    entry.add(seq, secondList.get(j));
...
Object[]sortLoops(ArrayList list)
sort Loops
Object o[] = list.toArray();
Arrays.sort(o);
return o;
MapsortMap(Map targetMap, List sortedList)
sort Map
LinkedHashMap sortedMap = new LinkedHashMap();
Iterator var3 = sortedList.iterator();
while (var3.hasNext()) {
    Object k = var3.next();
    if (targetMap.get(k) != null) {
        sortedMap.put(k, targetMap.get(k));
return sortedMap;
voidsortMapEntryListByValue(List> entries, boolean descending)
Sorts a List of Map.Entry into descending or ascending order by value
final int order = descending ? -1 : 1;
Collections.sort(entries, new Comparator<Map.Entry<String, Integer>>() {
    public int compare(Map.Entry<String, Integer> e1, Map.Entry<String, Integer> e2) {
        Integer e1Value = e1.getValue();
        Integer e2Value = e2.getValue();
        return order * (e1Value.compareTo(e2Value));
    public boolean equals(Object obj) {
...
voidsortMessages(List ms)
sort Messages
Collections.sort(ms, new Comparator<Hashtable>() {
    @Override
    public int compare(Hashtable o1, Hashtable o2) {
        Integer n1 = (Integer) o1.get("sortPriority");
        if (n1 == null)
            n1 = 3;
        Integer n2 = (Integer) o2.get("sortPriority");
        if (n2 == null)
...
StringsortNames(List nameLs, String splitStr)
Sort the List Strings from back to front and split them with split.
StringBuffer strs = new StringBuffer();
if (!nameLs.isEmpty()) {
    for (int i = nameLs.size() - 1; i >= 0; i--) {
        strs.append(nameLs.get(i));
        if (i != 0) {
            strs.append(splitStr);
return strs.toString();