code: public static void swap(Array array, int left, int right) throws ExpressionException {
  	int len = array.size();
  
  	if (len == 0) throw new ExpressionException("array is empty");
  	if (left < 1 || left > len) throw new ExpressionException("invalid index [" + left + "]", "valid indexes are from 1 to " + len);
  	if (right < 1 || right > len) throw new ExpressionException("invalid index [" + right + "]", "valid indexes are from 1 to " + len);
  
  	try {
  	    Object leftValue = array.get(left, null);
  	    Object rightValue = array.get(right, null);
  
  	    array.setE(left, rightValue);
  	    array.setE(right, leftValue);
  	}
  	catch (PageException e) {
  	    throw new ExpressionException("can't swap values of array", e.getMessage());
  	}
  
      }
docs: swap to values of the array
  
  @param array
  @param left left value to swap
  @param right right value to swap
  @throws ExpressionException