Return the items of an Iterable as a sorted list.

@param <T>
The type of items in the Iterable.
@param items
The collection to be sorted.
@return A list containing the same items as the Iterable, but sorted.
961715
public static <T> List<T> sorted(Iterable<T> items, Comparator<T> comparator) {
    List<T> result = toList(items);
    Collections.sort(result, comparator);
    return result;
  }
925597
public static <T> List<T> asList(Iterable<T> iterable) {
        List<T> result = new ArrayList<>();
        for (T item : iterable) {
            result.add(item);
        }
        return result;
    }
1314626
private static <T> ArrayList<T> sorted(Collection<T> cls, Comparator<? super T> c) {
    ArrayList<T> sorted = new ArrayList<>(cls);
    sorted.sort(c);
    return sorted;
  }
326216
public static <T> T max(T[] items) {
        return max((Iterable<T>)Arrays.asList(items));
    }
1162050
public static <T> List<T> toList(Iterable<T> items) {
    List<T> list = new ArrayList<T>();
    addAll(list, items);
    return list;
  }
280309
public static <T> Matcher<Iterable<T>> hasItems(Iterable<T> items) {
        List<Matcher<? super Iterable<T>>> all = new LinkedList<Matcher<? super Iterable<T>>>();
        for (T element : items) {
            all.add(hasItem(element));
        }

        return allOf(all);
    }
127681
public boolean addAll(Collection<T> items)
	{
		boolean wasAllAdded = true;
		for (T item : items)
		{
			if(!add(item))
				wasAllAdded = false;
		}
		
		return wasAllAdded;
	}
622685
public static <T> List<T> toList(Iterable<T> iterable) {
        List<T> list = null;

        if (iterable != null) {
            list = new ArrayList<>();
            for (T elem : iterable) {
                list.add(elem);
            }
        }

        return list;
    }
429333
public void setItems(java.util.Collection<ApiMapping> items) {
        if (items == null) {
            this.items = null;
            return;
        }

        this.items = new java.util.ArrayList<ApiMapping>(items);
    }
242456
public List<T> toSortedList() {
    List<T> sortedItems = Lists.newArrayList();
    while (size() > 0) {
      sortedItems.add(removeMin());
    }
    Collections.reverse(sortedItems);
    return sortedItems;
  }
256160
public static List<Item> toItemList(List<Map<String, AttributeValue>> items) {
        if (items == null) {
            return Collections.emptyList();
        }
        List<Item> result = new ArrayList<Item>(items.size());
        for (Map<String, AttributeValue> item : items) {
            result.add(toItem(item));
        }
        return result;
    }
1280821
public SetBuilder<T> add(T... items) {
        set.addAll(Arrays.asList(items));
        return this;
    }
269865
protected <T> List<? extends List<T>> toArrayLists(List<List<T>> lists) {
        for (int i = 0; i < lists.size(); i++) {
            List<T> list = lists.get(i);
            lists.set(i, toArrayList(list));
        }
        return lists;
    }
869183
public static Expression asList(Iterable<? extends Expression> items) {
    final ImmutableList<Expression> copy = ImmutableList.copyOf(items);
    if (copy.isEmpty()) {
      return MethodRef.IMMUTABLE_LIST_OF.get(0).invoke();
    }
    // Note, we cannot necessarily use ImmutableList for anything besides the empty list because
    // we may need to put a null in it.
    final Expression construct = ConstructorRef.ARRAY_LIST_SIZE.construct(constant(copy.size()));
    return new Expression(ARRAY_LIST_TYPE, Feature.NON_NULLABLE) {
      @Override
      protected void doGen(CodeBuilder mv) {
        construct.gen(mv);
        for (Expression child : copy) {
          mv.dup();
          child.gen(mv);
          MethodRef.ARRAY_LIST_ADD.invokeUnchecked(mv);
          mv.pop(); // pop the bool result of arraylist.add
        }
      }
    };
  }
101616
public static <T> T first(List<T> items) {
        if(items != null && items.size() > 0) {
            return items.get(0);
        }

        return null;
    }
387873
public static <T> boolean addAll(Collection<T> self, Iterator<T> items) {
        boolean changed = false;
        while (items.hasNext()) {
            T next =  items.next();
            if (self.add(next)) changed = true;
        }
        return changed;
    }
658546
public static <T, L extends List<T>> L sortThis(L list, Comparator<? super T> comparator)
    {
        if (list instanceof MutableList)
        {
            ((MutableList<T>) list).sortThis(comparator);
        }
        else if (list instanceof ArrayList)
        {
            ArrayListIterate.sortThis((ArrayList<T>) list, comparator);
        }
        else
        {
            if (list.size() > 1)
            {
                Collections.sort(list, comparator);
            }
        }
        return list;
    }