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

voidsortInputQueryKeys(List l)
Sort the input query list
for (int i = 0; i < l.size(); i++) {
    for (int j = 0; j < l.size() - 1; j++) {
        String k1 = (String) l.get(j);
        int k = j + 1;
        String k2 = (String) l.get(k);
        String i1 = k1.substring(k1.indexOf(":") + 1, k1.indexOf("_"));
        String i2 = k2.substring(k2.indexOf(":") + 1, k2.indexOf("_"));
        if (Integer.decode(i1).intValue() > Integer.decode(i2).intValue()) {
...
voidsortItems(List items, String putOnTop)
Sort the given items in a natural order.
boolean topItemIn = items.contains(putOnTop);
Collections.sort(items);
if (topItemIn) {
    items.remove(putOnTop);
    items.add(0, putOnTop);
ArrayListsortList(ArrayList list)
Sorts a given ArrayList.
Object[] a = list.toArray();
Arrays.sort(a);
list.clear();
for (int i = 0; i < a.length; i++)
    list.add(a[i]);
return list;
ListsortList(Collection list)
a small utility function for sorting a list
ArrayList<T> ret = new ArrayList<T>();
ret.addAll(list);
Collections.sort(ret);
return ret;
java.util.ListsortList(java.util.List types)
sort List
try {
    java.util.Collections.sort(types); 
} catch (Exception e) {
return types;
ListsortList(List list)
sort List
Collections.sort(list, new Comparator() {
    public int compare(Object o1, Object o2) {
        Object[] oo1 = (Object[]) o1;
        Object[] oo2 = (Object[]) o2;
        return (((String) oo1[0]).compareTo((String) oo2[0]));
});
return list;
...
voidsortList(List items)
sort List
Collections.sort(items, String.CASE_INSENSITIVE_ORDER);
ListsortList(List list, boolean asc)
sort List
if (list == null) {
    return list;
list.sort((T a, T b) -> {
    if (asc) {
        return a.compareTo(b);
    } else {
        return b.compareTo(a);
...
voidsortListAlphabetically(List list)
Returns an alphabetically sorted copy of vector.
Collections.sort(list, new Comparator() {
    public int compare(Object a, Object b) {
        String textA = a.toString();
        String textB = b.toString();
        return textA.compareToIgnoreCase(textB);
});
voidsortListByMapKey(List> list)
sort List By Map Key
Collections.sort(list, new Comparator<Map<String, Object>>() {
    @Override
    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
        String name = o1.get("key").toString();
        String _name = o2.get("key").toString();
        int n1 = name.length(), n2 = _name.length();
        for (int i1 = 0, i2 = 0; i1 < n1 && i2 < n2; i1++, i2++) {
            char c1 = name.charAt(i1);
...