I just finished this assignment successfully with a lot of effort!
Looks like you created a custom function to sort, which is not needed. Here's how I did it:
count the total votes of all remaining candidates
if any of the remaining candidates have more than
total votes / 2 + 1, they are the winner
** in both steps, only consider remaining candidates