add almost sorted input and fix use of private stdlib-function