Common code of several ordered list implementations.