Sam is an avid collector of numbers. Every time he finds a new number he throws it on the top of his number-pile. Help Sam organise his collection so he can take it to the International Number Collectors Conference in Cologne. 

Given an array of numbers, your function should return an array of arrays, where each subarray contains all the duplicates of a particular number. Subarrays should be in the same order as the first occurence of the number they contain:
Assume the input is always going to be an array of numbers. If the input is an empty array, an empty array should be returned.

Difficulty: EASY
Starter code: def group(arr):
	

Solutions:
group = lambda arr: [[n] * arr.count(n) for n in sorted(set(arr), key=arr.index)]


from collections import Counter, OrderedDict

class OrderedCounter(Counter, OrderedDict):
	pass

def group(arr):
	return [[k] * v for (k, v) in OrderedCounter(arr).items()]


from collections import OrderedDict

def group(arr):
	d = OrderedDict()
	for x in arr:
		d.setdefault(x, []).append(x)
	return list(d.values())


def group(arr):
	return [[n] * arr.count(n) for (i, n) in enumerate(arr) if arr.index(n) == i]


def group(arr):
	(st, res) = (set(arr), [])
	for n in arr:
		if n in st:
			st.remove(n)
			res.append([n] * arr.count(n))
	return res


def group(arr):
	lst = [[i] * arr.count(i) for i in arr]
	re = []
	for n in lst:
		if n not in re:
			re.append(n)
	return re


from collections import Counter

def group(a):
	return sorted([[k] * v for (k, v) in Counter(a).items()], key=lambda k: a.index(k[0]))


from collections import Counter

def group(arr):
	return [[k] * n for (k, n) in Counter(arr).items()]


def group(arr):
	(answer, brac, counter, already) = ([], [], 0, [])
	for i in arr:
		if arr.count(i) > 1 and i not in already:
			already.append(i)
			while counter < arr.count(i):
				counter += 1
				brac.append(i)
				if counter == arr.count(i):
					answer.append(brac)
					brac = []
					counter = 0
					break
		elif arr.count(i) == 1:
			answer.append([i])
	return answer


def group(lst):
	return [[n] * lst.count(n) for n in sorted(set(lst), key=lst.index)]