Please do not post the same topic in two different threads. You’ve already opened this exact issue in your other thread here: What is Julia's maxk(Matlab) that returns the indice of top K largest values? - #11 by platawiec
Duplicating a topic makes it harder for us to help you: people end up duplicating each other’s responses and the correct answer gets divided up into multiple places.