@Override
 public Value apply(Spreadsheet s, List<Expression> args) {
   SubExpression sx = (SubExpression) args.get(0);
   Value lv = sx.left.evaluate(s);
   Value rv = sx.right.evaluate(s);
   if (lv.getClass() == CellReference.class && rv.getClass() == CellReference.class) {
     return (new RegionReference(
             ((CellReference) lv).colIdx,
             ((CellReference) lv).rowIdx,
             ((CellReference) rv).colIdx,
             ((CellReference) rv).rowIdx))
         .average(s);
   } else {
     return new ErrorValue("Cannot find sum of anything but a cell region");
   }
 }
    @Override
    public Value apply(Spreadsheet s, List<Expression> args) {
      try {
        if (args.get(0).getClass() == Identifier.class) {
          Identifier id = (Identifier) args.get(0);
          s.sort(id.nm.toUpperCase().charAt(0));
          return null;
        }
        Value temp = args.get(0).evaluate(s).resolve(s);
        if (temp.getClass() == Number.class) {
          s.sort((int) (((Number) temp).v));
        }
      } catch (ClassCastException e) {
        System.out.println(
            "Error: "
                + e.getMessage()
                + "\nEnsure that the row/column only contains numbers or strings\n");
      }

      return null;
    }
 @Override
 public Value apply(Spreadsheet s, List<Expression> args) {
   Value a = args.get(0).evaluate(s).resolve(s);
   Value b = args.get(1).evaluate(s).resolve(s);
   switch (op) {
     case less:
       return a.compareTo(b) < 0 ? TrueValue.get() : null;
     case lesseq:
       return a.compareTo(b) <= 0 ? TrueValue.get() : null;
     case eq:
       return a.compareTo(b) == 0 ? TrueValue.get() : null;
     case grtr:
       return a.compareTo(b) > 0 ? TrueValue.get() : null;
     case grtreq:
       return a.compareTo(b) >= 0 ? TrueValue.get() : null;
     case noteq:
       return a.compareTo(b) != 0 ? TrueValue.get() : null;
     default:
       return null;
   }
 }