Parsing a complicated CSV generated on election nights
# Make one more candidate than necessary into winners list
winners = sorted(cnds, key=lambda k: int(k['votes'], reverse=True)[0:num_win + 1]

# A tie to be resolved happens when two last candidates have equal vote count.
# if so, go backwards removing everybody with the same vote count.
# Binary search would work faster, of course. If a standard library 
# provides something similar to std::lower_bound from STL -  its even better.

index = num_win
while index &gt; 0 and winners[index - 1]['votes'] == winners[num_win]['votes']:
    index -= 1

# Finally, adjust your list
winners = winners[0:index]


PS: One more thing to mention. The final nested loop is not really the best approach. You should decorate the original list with the sequential numbers (or use some other method to remember initial ordering), sort it, mark the winners which are at the beginning of the list, and sort it by sequence numbers back to the original state.