# [R](https://www.r-project.org), 56 bytes ```r \(e,d,l,u=e<d,`+`=sort)c(c(d,l[i<-!(l>e)-u])+!u,l[!i]+u) ``` [Attempt This Online!](https://ato.pxeger.com/run?1=fY1BCsIwFETX9RRml0_nQ2MbrNB4ELVQSBMoFAq1OY2bKHgob2OKXbuZgXkzzOM5x5c377B4rj_1TTr0GBGMa3p0eWfu07yQlVam-Do0LOR4dsShpVyEFImhzQNt-4uXBfYlsszKCnwAaySpoKCJdivlP1RDpXmiCiWOOEGptc-qoO0hxp9_AQ) **How?** Ungolfed code: uses the ```descending``` argument of ```sort``` to control sorting order: ``` f=function(e,d,l){ # e=entry, d=destination, l=list of passenger floors u=e<d # u=boolean: TRUE=going up; FALSE=going down i=!(l>e)-u # i=elements of l in the first direction c( # join together the first & second directions sort(c(d,l[i]) # sort the stops in the first direction... ,!u) # using 2nd arg of sort: descending TRUE/FALSE=!u ,sort(l[!i] # sort the stops in the second direction ,u) # in the other order: descending TRUE/FALSE=u ) ```