You don't say how "it doesn't work" but List::Utils min() returns the minimum value not its index. You could use
List::MoreUtils first_index() function to then find the index, or adapt one of the solutions in
How can I find the index of the biggest element in an array?