How to find the position of the smaller element in the list
Flatten @ Position[Less @@@ Transpose[{x, y}], True]
Flatten@Position[Negative[x - y], True]
Also possible:
Flatten@Position[x - y, _?(# < 0 &)]
or, as suggested by J.M.,
Flatten[Position[x - y, _?Negative]]
PositionIndex[Sign[x - y]] @ -1
{2, 3, 6}
Also
PositionIndex[UnitStep[x - y]] @ 0 (* thanks: J.M. *)
{2, 3, 6}
PositionIndex[Negative[x - y]] @ True (* thanks: anderstood *)
{2, 3, 6}
PositionIndex[Thread[x < y]]@True
{2, 3, 6}
If you prefer to have {}
(rather than Missing["KeyAbsent", _]
) as output when no positions satisfy the condition, you can use
Lookup[PositionIndex[Sign[x - y]], -1, {}]
Lookup[PositionIndex[UnitStep[x - y]], 0, {}]
Lookup[PositionIndex[Negative[x - y]], True, {}]
Lookup[PositionIndex[Thread[x < y]], True, {}]
for the four approaces above.