isSorted: {[xs]
isSortedInner:{[xs;i;len]
$[i>=len;1; (
$[xs[i]<xs[i-1];
0;
.z.s[xs;i+1;len]
]
)]
};
len: count xs;
isSortedInner[xs;1;len]
};
This is recursive port of the python logic. Took me over an hour because I don't know KDB.
I doubt this is idiomatic or the fastest way of doing it. I don't even know if it's space efficient because of the recursion.