You are standing on top of an amazing Himalayan mountain. The view is absolutely breathtaking! you want to take a picture on your phone, but... your memory is full again! ok, time to sort through your shuffled photos and make some space...

Given a gallery of photos, write a function to sort through your pictures.
You get a random hard disk drive full of pics, you must return an array with the 5 most recent ones PLUS the next one (same year and number following the one of the last).

You will always get at least a photo and all pics will be in the format `YYYY.imgN`

Examples:
```python
sort_photos["2016.img1","2016.img2","2015.img3","2016.img4","2013.img5"]) ==["2013.img5","2015.img3","2016.img1","2016.img2","2016.img4","2016.img5"]
sort_photos["2016.img1"]) ==["2016.img1","2016.img2"]
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def sort_photos(pics):
	

Solutions:
def sort_photos(lst):
	lst = [[int(d) for d in f.split('.img')] for f in lst]
	(s, l) = (sorted(lst), min(len(lst), 5))
	return [f'{y}.img{n + (i == l)}' for (i, (y, n)) in enumerate(s[-5:] + s[-1:])]


def sort_photos(pics):
	tmp = sorted(((pic[:8], int(pic[8:])) for pic in pics))
	return [x + str(y) for (x, y) in tmp[-5:]] + [tmp[-1][0] + str(tmp[-1][1] + 1)]


def sort_photos(pics):
	out = sorted(pics, key=lambda i: (int(i[:4]), int(i.split('g')[-1])))[:-6:-1][::-1]
	out.append(out[-1].split('g')[0] + 'g' + str(int(out[-1].split('g')[-1]) + 1))
	return out


import re
SEQ_PATTERN = re.compile('\\.img')

def sort_photos(pics):
	sortedPics = sorted((list(map(int, SEQ_PATTERN.split(p))) + [p] for p in pics))
	(lastY, lastN, _) = sortedPics[-1]
	return [p for (_, _, p) in sortedPics[-5:]] + ['{}.img{}'.format(lastY, lastN + 1)]


def sort_photos(pics):
	s = [[int(i.split('.img')[0]), int(i.split('.img')[1])] for i in pics]
	s.sort()
	s.append([s[-1][0], s[-1][1] + 1])
	return [str(i[0]) + '.img' + str(i[1]) for i in s][-6:]


def sort_photos(pics):
	pic2 = sorted([[int(i) for i in x.split('.img')] for x in pics])[-5:]
	return [str(i[0]) + '.img' + str(i[1]) for i in pic2] + [str(pic2[-1][0]) + '.img' + str(pic2[-1][1] + 1)]


def key(pic):
	parts = pic.split('.')
	return (parts[0], int(parts[1][3:]))

def sort_photos(pics):
	pics.sort(key=key)
	pics = pics[-5:]
	last_key = key(pics[-1])
	pics.append(last_key[0] + '.img' + str(last_key[1] + 1))
	return pics