Problem with C1_W4_Assignment: UNQ_C9 Getting KNN in reverse order

UNQ_C9 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)

You do not have to input any code in this cell, but it is relevant to grading, so please do not change anything

Test your implementation:

v = np.array([1, 0, 1])
candidates = np.array([[1, 0, 5], [-2, 5, 3], [2, 0, 1], [6, -9, 5], [9, 9, 9]])
print(candidates[nearest_neighbor(v, candidates, 3)])
[[9 9 9] [1 0 5] [2 0 1]]

Expected Output:

[[2 0 1] [1 0 5] [9 9 9]]

My list of KNN is just the reverse of expected output. Not sure what is going wrong here.
Need some help to troubleshoot.

Hi @stripathi
I suspect you should to take another look at your nearest_neighbor function (in UNQ_C8), especially to # Reverse the order of the sorted_ids array part - make sure it reverses the order correctly :slight_smile:

I faced the same issue and solved by adding [::-1] at the end line as :
return k_idx[::-1]