The problem is sorting the 2-dim array, which your treatment does not show. Converting it to 1-dim, sorting, converting back is a solution that does not require much manipulation. Best Regards,
I think we're answering different questions! My reading of the original question is that we don't want to sort the whole array - we want to find the minimum value in the third column, and then return the corresponding values in the first two columns.
The example given is that the "lookup" value is 2, and the returned values are -1, -2. Your sorting approach leaves two -2 values.
So IMHO my answer is right, and your answer is right to the question "I've got a two dimensional array and I want to know the lowest 2 values held in it".
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.