> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metrics-man.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Max

# \$max

The `$max` operator returns the larger of two values. If the values are of numeric type, it compares them numerically. If they are strings, it performs lexicographic comparison.

## Input

* An array containing exactly two values to compare

## Output

* The larger of the two input values

## Examples

### Numeric Comparison

```json theme={null}
{
  "$max": [
    5,
    10
  ]
}
```

Result: `10`

### String Comparison

```json theme={null}
{
  "$max": [
    "apple",
    "banana"
  ]
}
```

Result: `"banana"`

### Field Value Comparison

```json theme={null}
{
  "$max": [
    {
      "$input": "score1"
    },
    {
      "$input": "score2"
    }
  ]
}
```

Result: The higher score between score1 and score2
