Question: 
Write a function to sort the given list based on the occurrence of first element of tuples.


Model's Code:
def sort_on_occurence(lst):
    from collections import Counter
    count = Counter(x[0] for x in lst)
    sorted_lst = sorted(lst, key=lambda x: count[x[0]], reverse=True)
    return [(x[0], *x[1:], count[x[0]]) for x in sorted_lst]



Sample Correct Code:
def sort_on_occurence(lst): 
	dct = {} 
	for i, j in lst: 
		dct.setdefault(i, []).append(j) 
	return ([(i, *dict.fromkeys(j), len(j)) 
				for i, j in dct.items()]) 


Asserts:
assert sort_on_occurence([(1, 'Jake'), (2, 'Bob'), (1, 'Cara')]) == [(1, 'Jake', 'Cara', 2), (2, 'Bob', 1)]
assert sort_on_occurence([('b', 'ball'), ('a', 'arm'), ('b', 'b'), ('a', 'ant')]) == [('b', 'ball', 'b', 2), ('a', 'arm', 'ant', 2)]
assert sort_on_occurence([(2, 'Mark'), (3, 'Maze'), (2, 'Sara')]) == [(2, 'Mark', 'Sara', 2), (3, 'Maze', 1)]


Tests:
Test 1 of 3: FAIL: AssertionError()

Test 243 of 974: 175/243 (72.0164609053498%): failed