R, 47 bytes
\(e,d,l,m=c(d,l))m[order(!(m<e)-(e<d),(m-e)^2)]
Approach copied from Jonah's answer - upvote that one!
Previously: R, 56 bytes
\(e,d,l,u=e<d,`+`=sort)c(c(d,l[i<-!(l>e)-u])+!u,l[!i]+u)
Uses the decreasing
argument of sort
to control sorting order.