@SuppressWarnings("unchecked")
	public ArrayList<E> toSortedList(Comparator<? super E> cmp)
	{
		E[] sorted = (E[]) data.clone();
		for(int i = 1; i<size; i++){
			E val = sorted[i];
			int j;
			for(j = i-1; j>=0 && cmp.compare(sorted[j], val) > 0; j--)
				sorted[j+1] = sorted[j];
			sorted[j+1] = val;
		}
	   
		ArrayList<E> result = new ArrayList<E>();
		result.add((E) sorted);
		return result;
	}