Find all real-valued functions $f$ defined on pairs of real numbers, having the following property: for all real numbers $a, b, c$, the median of $f(a,b), f(b,c), f(c,a)$ equals the median of $a, b, c$.

(The [i]median[/i] of three real numbers, not necessarily distinct, is the number that is in the middle when the three numbers are arranged in nondecreasing order.)
1. **Initial Observation**:
   - The median of three identical numbers \(a, a, a\) is \(a\). Therefore, the median of \(f(a, a), f(a, a), f(a, a)\) must also be \(a\). This implies:
     \[
     f(a, a) = a
     \]

2. **Considering \(a < b\)**:
   - The median of \(a, a, b\) is \(a\). Therefore, the median of \(f(a, a), f(a, b), f(b, a)\) must also be \(a\). This implies:
     \[
     a = \text{median}(f(a, b), a, f(b, a))
     \]
     Hence:
     \[
     \min(f(a, b), f(b, a)) \leq a \leq \max(f(a, b), f(b, a))
     \]

3. **Considering \(a, b, b\)**:
   - The median of \(a, b, b\) is \(b\). Therefore, the median of \(f(a, b), f(b, b), f(b, a)\) must also be \(b\). This implies:
     \[
     b = \text{median}(f(a, b), b, f(b, a))
     \]
     Hence:
     \[
     \min(f(a, b), f(b, a)) \leq b \leq \max(f(a, b), f(b, a))
     \]

4. **Combining the Inequalities**:
   - From the above two inequalities, we get:
     \[
     \min(f(a, b), f(b, a)) \leq a < b \leq \max(f(a, b), f(b, a))
     \]
   - By symmetry, for any \(a, b\):
     \[
     \min(f(a, b), f(b, a)) \leq \min(a, b) \leq \max(a, b) \leq \max(f(a, b), f(b, a))
     \]
   - This implies that \(f(a, b)\) and \(f(b, a)\) must be either \(\min(a, b)\) or \(\max(a, b)\).

5. **Assuming \(f(a, b) \neq b\) and \(f(b, a) \neq b\)**:
   - For any \(c > b\), the median of \(a, b, c\) must be the median of \(f(a, b), f(b, c), f(c, a)\). Since \(f(c, a) \neq b\) and \(f(a, b) \neq b\), it follows that \(f(b, c) = b\) for all \(c > b\).
   - Similarly, for any \(c > b\), the median of \(a, b, c\) must be the median of \(f(a, c), f(c, b), f(b, a)\). Since \(f(a, c) \neq b\) and \(f(b, a) \neq b\), it follows that \(f(c, b) = b\) for all \(c > b\).

6. **Considering \(b < c < d\)**:
   - The median of \(b, c, d\) must be the median of \(f(b, c), f(c, d), f(d, b)\). Since \(f(b, c) = b\) and \(f(d, b) \neq c\), it follows that \(f(c, d) = c\).
   - Similarly, the median of \(f(b, d), f(d, c), f(c, b)\) must be the median of \(b, c, d\). Since \(f(c, b) = b\) and \(f(b, d) \neq c\), it follows that \(f(d, c) = c\).

7. **Contradiction**:
   - For \(b < c < d < e\), the median of \(c, d, e\) must be the median of \(f(c, d), f(d, e), f(e, c)\). Since \(f(c, d) = c\), \(f(d, e) = d\), and \(f(e, c) = c\), the median is \(c\), which contradicts the requirement that the median is \(d\).

8. **Conclusion**:
   - Therefore, one of \(f(a, b)\) or \(f(b, a)\) must be \(b\). Similarly, one of \(f(a, b)\) or \(f(b, a)\) must be \(a\). Hence, \(\{f(a, b), f(b, a)\} = \{a, b\}\).

9. **Final Function Forms**:
   - If \(f(a, b) = a\), then for any \(x, y\), \(f(x, y) = x\).
   - If \(f(a, b) = b\), then for any \(x, y\), \(f(x, y) = y\).

The final answer is \( \boxed{ f(x, y) = x } \) or \(f(x, y) = y\).