Python dictionaries are inherently unsorted. So what do you do if you need to sort the contents of a dictionary?

Create a function that returns a sorted list of `(key, value)` tuples (Javascript: arrays of 2 items).

The list must be sorted by the `value` and be sorted **largest to smallest**.

## Examples

```python
sort_dict({3:1, 2:2, 1:3}) == [(1,3), (2,2), (3,1)]
sort_dict({1:2, 2:4, 3:6}) == [(3,6), (2,4), (1,2)]
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Sorting

Data structures

Starter code: def sort_dict(d):
	

Solutions:
def sort_dict(d):
	return sorted(d.items(), key=lambda x: x[1], reverse=True)


from operator import itemgetter

def sort_dict(d):
	return sorted(d.items(), key=itemgetter(1), reverse=True)


def sort_dict(d):
	return sorted(d.items(), key=lambda x: -x[1])


def sort_dict(d):
	return sorted(list(d.items()), key=lambda i: -i[1])


def sort_dict(d):
	a = []
	for x in d:
		a.append((x, d[x]))
	for i in range(0, len(a)):
		for j in range(i + 1, len(a)):
			if a[i][1] < a[j][1]:
				temp = a[j]
				a[j] = a[i]
				a[i] = temp
	return a


def sort_dict(d):
	return sorted(d.items(), key=lambda pair: pair[1], reverse=True)