assert in most languages is a boolean that crashes the program if it is false.

If you want to assert that a list is sorted, you need some function that checks if it is sorted and returns a boolean.

In many (most?) languages assert is an optional crash if false. The language can choose to run the check or not. A function to check if a list is sorted and return a boolean is not hard to write - but of course you then need to prove that function is correct.