Write a program that outputs the `n` largest elements from a list.

Example:
```python
largest(2, [7,6,5,4,3,2,1])
# => [6,7]
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def largest(n,xs):
	

Solutions:
def largest(n, xs):
	return sorted(xs)[-n:]


def largest(n, xs):
	import heapq
	return heapq.nlargest(n, xs)[::-1]


def largest(n, xs):
	xs.sort()
	return xs[-n:]


import heapq

def largest(n, xs):
	return sorted(heapq.nlargest(n, xs))


largest = lambda n, x: sorted(x)[-n:]


largest = lambda n, a: a.sort() or a[-n:]


def largest(n, xs):
	lst = sorted(xs)
	new = []
	for i in range(n):
		new.append(lst[-i - 1])
	return sorted(new)


def largest(n, xs):
	return sorted(xs, reverse=True)[0:n][::-1]