# Checking if a number is right sorted

I have a number $$n$$ such that the digits of $$n$$ are strictly increasing to the left except for the first digit. So for example when $$n=51369$$ fits the bill because:

$$1<3<6<9\tag1$$

Is there a way to write Mathematica code that checks if the number $$n$$ satisfy this criterion?

f1 = OrderedQ @* Rest @* IntegerDigits;

f1 /@ {51369, 51396}

{True, False}

f2 = Apply[LessEqual @ ##2 &] @* IntegerDigits;

f2 /@ {51369, 51396}

{True, False}

f = AllTrue[Rest[Differences[IntegerDigits[#]]], Positive] &


Test:

f /@ {51369, 412345, 824699, 41395, 31832}


True, True, False, False, False}

EDIT Visually,

alist = Range[1000];
blist = (Boole /@
f /@ alist) /. {{} -> Black, 0 -> Red, 1 -> Darker@Green} //
Multicolumn


A slight variation on the method given by @kglr

51369//IntegerDigits[#,10,IntegerLength[#]-1]&//OrderedQ
(* True *)


Using SequenceCount

f = SequenceCount[Rest @ IntegerDigits[#], x_ /; LessEqual @@ x] == 1 &;

f /@ {51369, 51396}


{True, False}

Using Split:

f = Length@Split[Rest@IntegerDigits[#], LessEqual] == 1 &;

f /@ {51369, 51396}

(*{True, False}*)