In my class, we showed that if $B$ is closed in $\mathbb{R}$ and $A\subseteq\mathbb{R}$ and every $x\in A$ has the unique nearest point $f\left(x\right)$ of $B$, then $x\mapsto f\left(x\right)$ is continuous.
My professor asked if we could find an arbitrary metric space $X$ (not necessarily with $X=\mathbb{R}$) where $A$ and $B$ (with $B$ not necessarily having to be closed now) have this same unique nearest point property, but $f$ is no longer continuous.
I've been thinking about it for a couple of days now, but I haven't come up with any examples. If anyone could provide an example, I would greatly appreciate it.