# UNQ_C8 Highest cosine but wrong order?

I’m getting the list of the 3 highest cosine_similarities but in the wrong order, and the grader fails it. 1) Right answers but wrong order would still be right wrt the actual output since they’re used as a set
2) I cannot figure out why this is happening. It’s trivial code and I just can’t see an error. I even wrote my own cosine similarity function to validate the one that’s given, and still get the top 3 but in a different order than the supposed correct output.
AND I get the same thing in UNQ_C22… right answers for the top 3 nearest neighbors but in the wrong order according to the grader. I think I’m right, especially when looking at the actual text being compared.

Ok - I “fixed” my code and got a perfect score. Instead of reversing the sorted index list and grabbing the top three, I just grabbed the last three and left them in that order. This returns them in NOT the sorted order, but at least the output matches the exam expectations.

@Ken_Otwell If you just take the bottom 3 those will be in the ascending order. So probably you are unknowingly reversing the order of indexes before knowingly reversing it. Or you are selecting the bottom 3 reversing them intrinsically.

Anyway, you must have known by now that the same thing happening to C22 as you call the function C8 in a loop here.

The order shouldn’t matter anyway - they’re a set of values - the top 3. Nothing should depend on which order they are returned. What the grader expects is actually in the wrong order, it wants number 3 first, then number 2, then number 1.