<p>
Creates an new instance of the list add the sorted list to it.
</p>

@param list the list which content should be ordered.
@param <T> the type of the list elements.
@return a new sorted list.
@see java.util.Collections#sort(List)
10199
public static <T extends Comparable<? super T>> List<T> sort(final List<T> list) {
        Validate.notNull(list, "Cannot execute list sort: list is null");
        final Object[] a = list.toArray();
        Arrays.sort(a);
        
        return fillNewList(a, list.getClass());
    }
686768
public static <T extends Comparable<? super T>> void sortReverse(List<T> list) {
		Collections.sort(list, Collections.reverseOrder());
	}
935272
public static <T> List<T> sortByProperty(List<T> list, String property) {
		return sort(list, new PropertyComparator<>(property));
	}
1235691
public <T extends Comparable<? super T>> List<T> sort (Iterator<T> iter)
    {
        ArrayList<T> list = new ArrayList<T>();
        CollectionUtil.addAll(list, iter);
        return sort(list);
    }
897956
public static function sort( &$list )
	{
		$n	= count( $list );
		$i	= 0;
		while( $i < $n )
		{
			if( $i == 0 || $list[$i-1] <= $list[$i] )
				$i++;
			else
			{
				$tmp = $list[$i];
				$list[$i]	= $list[$i-1];
				$list[--$i] = $tmp;
			}
		}
	}
832735
public void sort(@NonNull Comparator<? super T> comparator) {
        final ArrayList<T> copy = new ArrayList<>(mObjects);
        Collections.sort(copy, comparator);
        swap(copy);
    }
11821
public static <E> void shuffle(List<E> list) {
        int swapPlace = -1;
        
        for(int i = 0; i < list.size(); i++) { 
            swapPlace = (int) (Math.random() * (list.size() - 1));
            TrivialSwap.swap(list, i, swapPlace);
        }
	}
1046076
public List<Order> create(OrderBy order) {
        List<Order> list = new ArrayList<>();

        for (SortSpecification sort : order.getSort()) {
            if (sort.getSortOrder() == SortOrder.DESC) {
                list.add(cb.desc(root.get(sort.getKey())));
            } else if (sort.getSortOrder() == SortOrder.ASC) {
                list.add(cb.asc(root.get(sort.getKey())));
            }
        }

        return list;
    }
906373
public void sort(Comparator<T> sort) {
		ArrayList<T> tmp = new ArrayList<T>();
		
        for( Collection<T> page : pages ) {
			tmp.addAll(page);
		}
		setup(tmp, pageSize, sort);
	}
190703
public SimpleOrderedMap<Object> create(ComponentList list, Boolean encode) {
    SimpleOrderedMap<Object> mtasListResponse = new SimpleOrderedMap<>();
    mtasListResponse.add("key", list.key);
    if (list.number == 0) {
      mtasListResponse.add("total", list.total);
    }
    if (list.output != null) {
      ArrayList<NamedList<Object>> mtasListItemResponses = new ArrayList<>();
      if (list.output.equals(ComponentList.LIST_OUTPUT_HIT)) {
        mtasListResponse.add("number", list.hits.size());
        for (ListHit hit : list.hits) {
          NamedList<Object> mtasListItemResponse = new SimpleOrderedMap<>();
          mtasListItemResponse.add("documentKey",
              list.uniqueKey.get(hit.docId));
          mtasListItemResponse.add("documentHitPosition", hit.docPosition);
          mtasListItemResponse.add("documentHitTotal",
              list.subTotal.get(hit.docId));
          mtasListItemResponse.add("documentMinPosition",
              list.minPosition.get(hit.docId));
          mtasListItemResponse.add("documentMaxPosition",
              list.maxPosition.get(hit.docId));
          mtasListItemResponse.add("startPosition", hit.startPosition);
          mtasListItemResponse.add("endPosition", hit.endPosition);

          SortedMap<Integer, List<List<String>>> hitData = new TreeMap<>();
          SortedMap<Integer, List<List<String>>> leftData = null;
          SortedMap<Integer, List<List<String>>> rightData = null;
          if (list.left > 0) {
            leftData = new TreeMap<>();
          }
          if (list.right > 0) {
            rightData = new TreeMap<>();
          }
          for (int position = Math.max(0,
              hit.startPosition - list.left); position <= (hit.endPosition
                  + list.right); position++) {
            List<List<String>> hitDataItem = new ArrayList<>();
            if (hit.hits.containsKey(position)) {
              for (String term : hit.hits.get(position)) {
                List<String> hitDataSubItem = new ArrayList<>();
                hitDataSubItem.add(CodecUtil.termPrefix(term));
                hitDataSubItem.add(CodecUtil.termValue(term));
                hitDataItem.add(hitDataSubItem);
              }
            }
            if (position < hit.startPosition) {
              if (leftData != null) {
                leftData.put(position, hitDataItem);
              }
            } else if (position > hit.endPosition) {
              if (rightData != null) {
                rightData.put(position, hitDataItem);
              }
            } else {
              hitData.put(position, hitDataItem);
            }
          }
          if (list.left > 0) {
            mtasListItemResponse.add("left", leftData);
          }
          mtasListItemResponse.add("hit", hitData);
          if (list.right > 0) {
            mtasListItemResponse.add("right", rightData);
          }
          mtasListItemResponses.add(mtasListItemResponse);
        }
      } else if (list.output.equals(ComponentList.LIST_OUTPUT_TOKEN)) {
        mtasListResponse.add("number", list.tokens.size());
        for (ListToken tokenHit : list.tokens) {
          NamedList<Object> mtasListItemResponse = new SimpleOrderedMap<>();
          mtasListItemResponse.add("documentKey",
              list.uniqueKey.get(tokenHit.docId));
          mtasListItemResponse.add("documentHitPosition", tokenHit.docPosition);
          mtasListItemResponse.add("documentHitTotal",
              list.subTotal.get(tokenHit.docId));
          mtasListItemResponse.add("documentMinPosition",
              list.minPosition.get(tokenHit.docId));
          mtasListItemResponse.add("documentMaxPosition",
              list.maxPosition.get(tokenHit.docId));
          mtasListItemResponse.add("startPosition", tokenHit.startPosition);
          mtasListItemResponse.add("endPosition", tokenHit.endPosition);

          ArrayList<NamedList<Object>> mtasListItemResponseItemTokens = new ArrayList<>();
          for (MtasToken token : tokenHit.tokens) {
            NamedList<Object> mtasListItemResponseItemToken = new SimpleOrderedMap<>();
            if (token.getId() != null) {
              mtasListItemResponseItemToken.add("mtasId", token.getId());
            }
            mtasListItemResponseItemToken.add("prefix", token.getPrefix());
            mtasListItemResponseItemToken.add("value", token.getPostfix());
            if (token.getPositionStart() != null) {
              mtasListItemResponseItemToken.add("positionStart",
                  token.getPositionStart());
              mtasListItemResponseItemToken.add("positionEnd",
                  token.getPositionEnd());
            }
            if (token.getPositions() != null) {
              mtasListItemResponseItemToken.add("positions",
                  Arrays.toString(token.getPositions()));
            }
            if (token.getParentId() != null) {
              mtasListItemResponseItemToken.add("parentMtasId",
                  token.getParentId());
            }
            if (token.getPayload() != null) {
              mtasListItemResponseItemToken.add("payload", token.getPayload());
            }
            if (token.getOffsetStart() != null) {
              mtasListItemResponseItemToken.add("offsetStart",
                  token.getOffsetStart());
              mtasListItemResponseItemToken.add("offsetEnd",
                  token.getOffsetEnd());
            }
            if (token.getRealOffsetStart() != null) {
              mtasListItemResponseItemToken.add("realOffsetStart",
                  token.getRealOffsetStart());
              mtasListItemResponseItemToken.add("realOffsetEnd",
                  token.getRealOffsetEnd());
            }
            mtasListItemResponseItemTokens.add(mtasListItemResponseItemToken);
          }
          mtasListItemResponse.add("tokens", mtasListItemResponseItemTokens);
          mtasListItemResponses.add(mtasListItemResponse);
        }
      }
      mtasListResponse.add(NAME, mtasListItemResponses);
    }
    return mtasListResponse;
  }
1217838
public static <T,W> List<T> listFirst(List<Pair<T, W>> list) {
        ArrayList<T> ts = new ArrayList<T>();
        for (Pair<T, W> twPair : list) {
            ts.add(twPair.getFirst());
        }
        return ts;
    }
700340
public static <E extends Comparable<E>> void sort(List<E> list) {
        while(!Sort.isSorted(list)) {
            FYShuffle.shuffle(list);
        }
    }
698188
public static final <T> void parallelQuickSort(List<T> list, Comparator<T> comparator)
    {
        ForkJoinPool pool = new ForkJoinPool();
        QuickSorter sorter = new QuickSorter(list, 0, list.size()-1, comparator);
        pool.invoke(sorter);
    }
245905
protected <T> List<T> toArrayList(List<T> list) {
        if (list == null) {
            return null;
        }
        if (!list.getClass().equals(ArrayList.class)) {
            list = new ArrayList<>(list);
        }
        return list;
    }
849721
public static <T> List<T> cast(List<?> list) {
    return list == null ? null : new CastingList<T>(list);
  }
1092760
@Override
    public C.List<T> prepend(C.List<T> list) {
        return prependList(list);
    }
994761
private static void sortMatchList(List<Match> list) {
    if (list != null) {
      // light sorting on start position
      Collections.sort(list, (Match m1,
          Match m2) -> (Integer.compare(m1.startPosition, m2.startPosition)));
    }
  }