Add express4 support to rearrangeMiddleware. Make sorting stable.