def count_and_first_index(it):
    dct_counts = {}
dct_first = {}
for idx, item in enumerate(it):
    if item in dct_counts:
        dct_counts[item] += 1
else:
    dct_counts[item] = 1
dct_first[item] = idx
return dct_counts, dct_first
python How do you sort list by occurrence with out removing elements from the list?