You get some nested lists. Keeping the original structures, sort only elements (integers) inside of the lists. In other words, sorting the intergers only by swapping their positions. 



```
Example
Input   : [[[2, 1], [4, 3]], [[6, 5], [8, 7]]]
Output  : [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
```

Note:
The structures of the lists are regular (symmetrical) and their depths are 3.

Difficulty: EASY
Tags: Fundamentals

Sorting
Skill types: Sorting

Starter code:
def sort_nested_list(A):
	

Solutions:
def sort_nested_list(xsss):
	ys = iter(sorted((x for xss in xsss for xs in xss for x in xs)))
	return [[[next(ys) for x in xs] for xs in xss] for xss in xsss]


import numpy as np

def sort_nested_list(A):
	return np.sort(A, axis=None).reshape(np.array(A).shape).tolist()


def sort_nested_list(array):
	numbers = iter(sorted((n for a1 in array for a2 in a1 for n in a2)))
	return [[[next(numbers) for n in a2] for a2 in a1] for a1 in array]


def sort_nested_list(A):
	numbers = []

	def peel(A, insert=False):
		for i in range(len(A)):
			if len(A[i]) != 0 and isinstance(A[i][0], list):
				A[i] = peel(A[i], insert)
			elif insert:
				A[i] = numbers[:len(A[i])]
				del numbers[:len(A[i])]
			else:
				numbers.extend(A[i])
		return A
	peel(A)
	numbers = sorted(numbers)
	return peel(A, insert=True)


import re

def sort_nested_list(arr):
	s = str(arr)
	ns = sorted(re.findall('\\d+', s), key=int, reverse=True)
	return eval(re.sub('\\d+', lambda _: ns.pop(), s))


def sort_nested_list(A, emol=''):
	for e in str(A):
		if e.isdigit() and emol[-1] is '}':
			continue
		emol += [e, '{}'][e.isdigit()]
	return eval(emol.format(*sorted([i for l in A for e in l for i in e])))


def fl(l):
	for x in l:
		if isinstance(x, list):
			for j in fl(x):
				yield j
		else:
			yield x

def sort_nested_list(a):
	numbers = iter(sorted(fl(a)))

	def b(n, a):
		return [next(n) if isinstance(c, int) else b(n, c) for c in a]
	return b(numbers, a)


from copy import deepcopy

def sort_nested_list(a):

	def seeker(lst):
		return lst if not lst or not isinstance(lst[0], list) else sum(map(seeker, lst), [])

	def putter(lst):
		for i in range(len(lst)):
			if isinstance(lst[i], list):
				putter(lst[i])
			else:
				lst[i] = next(elts)
	(a, elts) = (deepcopy(a), iter(sorted(seeker(a))))
	putter(a)
	return a


import re

def sort_nested_list(A):
	a = str(A)
	(b, a) = (a, re.sub('\\[|\\]', '', a))
	B = str(sorted(eval('[' + a + ']')))
	(b, nl) = (list(re.sub('\\d+', '#', b)), re.findall('\\d+', B)[::-1])
	for i in range(len(b)):
		b[i] = nl.pop() if b[i] == '#' else b[i]
	return eval(''.join(b))


def sort_nested_list(A):
	sort_nested_list.numbers = []

	def collect_numbers(lista):
		if len(lista) == 0:
			return lista
		if len(lista) > 1:
			for i in lista:
				try:
					for e in i:
						for q in e:
							sort_nested_list.numbers.append(q)
				except:
					return sorted(lista)
			return lista
		else:
			return [collect_numbers(lista[0])]

	def place_numbers(lista):
		if len(lista) == 0:
			return lista
		if len(lista) > 1:
			for i in lista:
				try:
					for e in i:
						for (index, element) in enumerate(e):
							e[index] = sort_nested_list.numbers.pop(0)
				except:
					return sorted(lista)
			return lista
		else:
			return [place_numbers(lista[0])]
	collect_numbers(A)
	sort_nested_list.numbers.sort()
	return place_numbers(A)