In this kata you will be given a sequence of the dimensions of rectangles ( sequence with width and length ) and circles ( radius - just a number ).  
Your task is to return a new sequence of dimensions, sorted ascending by area.

For example,

```python
seq = [ (4.23, 6.43), 1.23, 3.444, (1.342, 3.212) ] # [ rectangle, circle, circle, rectangle ]
sort_by_area(seq) => [ ( 1.342, 3.212 ), 1.23, ( 4.23, 6.43 ), 3.444 ]
```

This kata inspired by [Sort rectangles and circles by area](https://www.codewars.com/kata/sort-rectangles-and-circles-by-area/).

Source: codewars | Difficulty: EASY
Tags: Geometry

Fundamentals

Sorting

Mathematics

Starter code: def sort_by_area(seq):
	

Solutions:
def sort_by_area(seq):

	def func(x):
		if isinstance(x, tuple):
			return x[0] * x[1]
		else:
			return 3.14 * x * x
	return sorted(seq, key=func)


from math import pi as PI

def circle(r):
	return r * r * PI

def rect(a, b):
	return a * b

def getArea(r):
	return rect(*r) if isinstance(r, tuple) else circle(r)

def sort_by_area(seq):
	return sorted(seq, key=getArea)


def sort_by_area(seq):
	valueList = []
	for i in seq:
		if isinstance(i, tuple):
			l1 = i[0]
			l2 = i[1]
			area = l1 * l2
		else:
			area = 3.14 * i ** 2
		valueList.append(area)
	a = sorted(range(len(valueList)), key=valueList.__getitem__)
	sort_by_area = [seq[i] for i in a]
	return sort_by_area


from math import pi

def sort_by_area(a):
	return sorted(a, key=lambda x: x ** 2 * pi if isinstance(x, (int, float)) else x[0] * x[1])


from math import pi
from operator import mul

def area(args):
	try:
		return mul(*args)
	except TypeError:
		return pi * args ** 2

def sort_by_area(seq):
	return sorted(seq, key=area)


def sort_by_area(seq):
	lista = list()
	for x in seq:
		if type(x) == tuple:
			area = x[0] * x[1]
		else:
			area = 3.14 * x ** 2
		lista.append((area, x))
	return [x[1] for x in sorted(lista)]


def sort_by_area(arr):
	return sorted(arr, key=lambda x: x[0] * x[1] if isinstance(x, tuple) else x * x * 3.14)


def area(x):
	if type(x) == float or type(x) == int:
		return 3.141592653589 * x * x
	else:
		return x[0] * x[1]

def sort_by_area(seq):
	return sorted(seq, key=area)


from math import pi as PI

def sort_by_area(lst):
	return sorted(lst, key=lambda d: d[0] * d[1] if isinstance(d, tuple) else PI * d * d)


from math import pi

def sort_by_area(seq):
	return sorted(seq, key=lambda arg: arg[0] * arg[1] if isinstance(arg, tuple) else pi * arg ** 2)