public int connectRopes(int[] ropePieces){
		List<Integer> unsortedList = new ArrayList<Integer>();
		for(int i=0; i<ropePieces.length; i++){
			unsortedList.add(ropePieces[i]);
		}
		//Sort lengths is ascending order
		Collections.sort(unsortedList);
		int cost = 0;
		while(unsortedList.size() > 1){
			int combinedRopes = unsortedList.remove(0) + unsortedList.remove(0);
			cost = cost + combinedRopes;
			unsortedList.add(combinedRopes);
			Collections.sort(unsortedList);
		}
		
		return cost;
	}