Searchsorted with by and lookup

just to share, I found what I wanted, this way, using view:

a = [1,3,2,4,1,2,1];
is = sortperm(a);
va = view(a, is)
a[is[searchsorted(va, 3)]]
1 Like