I neither understand the downvote nor the close vote. I consider the question perfectly clear. The code example may not be strictly minimal, but the error is clear: always get "Is not sorted". So let’s not require the impossible of basic level programmers. — Ole V.V. 18 secs ago