Makes IsSorted contract helper that only runs in debug mode.