Solution using heapq and custom QueueItem object with comparator fails


Python solution fails using a custom QueueItem object with cmp() implemented.
Run as custom input does not consider the whole input (length :96, elements: 21). Solution is guaranteed to work, test and manual tests pass without a problem. Any tips on how to debug this?

import heapq

class QueueItem:
    def __init__(self, count, index):
       self.count = count
       self.index = index
    def __cmp__(self, other):
        if self.count > other.count:
            return 1
        elif self.count < other.count:
            return -1
            if self.index > other.index:
                return 1
            elif self.index < other.index:
                return -1
                return 0
class Solution:
    # @param A : string
    # @param B : list of strings
    # @return a list of integers
    def solve(self, A, B):
        for sen in B:
            print sen
        good_words = set(A.strip().split('_'))
        counts = []
        for item in B:
            count = len(good_words.intersection(set(item.split('_'))))
        # print counts
        h = []
        res = []
        for i,count in enumerate(counts):
            heapq.heappush(h, QueueItem(-count, i))
        while h:
        return res