Some new cashiers started to work at your restaurant. 

They are good at taking orders, but they don't know how to capitalize words, or use a space bar! 

All the orders they create look something like this:

`"milkshakepizzachickenfriescokeburgerpizzasandwichmilkshakepizza"`

The kitchen staff are threatening to quit, because of how difficult it is to read the orders. 

Their preference is to get the orders as a nice clean string with spaces and capitals like so:

`"Burger Fries Chicken Pizza Pizza Pizza Sandwich Milkshake Milkshake Coke"`

The kitchen staff expect the items to be in the same order as they appear in the menu. 

The menu items are fairly simple, there is no overlap in the names of the items:
```
1. Burger
2. Fries
3. Chicken
4. Pizza
5. Sandwich
6. Onionrings
7. Milkshake
8. Coke
```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def get_order(order):
	

Solutions:
def get_order(order):
	menu = ['burger', 'fries', 'chicken', 'pizza', 'sandwich', 'onionrings', 'milkshake', 'coke']
	clean_order = ''
	for i in menu:
		clean_order += (i.capitalize() + ' ') * order.count(i)
	return clean_order[:-1]


MENU = ['Burger', 'Fries', 'Chicken', 'Pizza', 'Sandwich', 'Onionrings', 'Milkshake', 'Coke']

def get_order(order):
	result = []
	for item in MENU:
		result.extend([item for _ in range(order.count(item.lower()))])
	return ' '.join(result)


menu = 'Burger Fries Chicken Pizza Sandwich Onionrings Milkshake Coke'.split()

def get_order(order):
	return ' '.join((item for item in menu for _ in range(order.count(item.lower()))))


def get_order(order):
	output = ''
	while order != '':
		if output == '':
			if order.find('burger') != -1:
				output += 'Burger'
				order = order.replace('burger', '', 1)
			elif order.find('fries') != -1:
				output += 'Fries'
				order = order.replace('fries', '', 1)
			elif order.find('chicken') != -1:
				output += 'Chicken'
				order = order.replace('chicken', '', 1)
			elif order.find('pizza') != -1:
				output += 'Pizza'
				order = order.replace('pizza', '', 1)
			elif order.find('sandwich') != -1:
				output += 'Sandwich'
				order = order.replace('sandwich', '', 1)
			elif order.find('onionrings') != -1:
				output += 'Onionrings'
				order = order.replace('onionrings', '', 1)
			elif order.find('milkshake') != -1:
				output += 'Milkshake'
				order = order.replace('milkshake', '', 1)
			elif order.find('coke') != -1:
				output += 'Coke'
				order = order.replace('coke', '', 1)
		elif output != '':
			if order.find('burger') != -1:
				output += ' Burger'
				order = order.replace('burger', '', 1)
			elif order.find('fries') != -1:
				output += ' Fries'
				order = order.replace('fries', '', 1)
			elif order.find('chicken') != -1:
				output += ' Chicken'
				order = order.replace('chicken', '', 1)
			elif order.find('pizza') != -1:
				output += ' Pizza'
				order = order.replace('pizza', '', 1)
			elif order.find('sandwich') != -1:
				output += ' Sandwich'
				order = order.replace('sandwich', '', 1)
			elif order.find('onionrings') != -1:
				output += ' Onionrings'
				order = order.replace('onionrings', '', 1)
			elif order.find('milkshake') != -1:
				output += ' Milkshake'
				order = order.replace('milkshake', '', 1)
			elif order.find('coke') != -1:
				output += ' Coke'
				order = order.replace('coke', '', 1)
	return output


import re
MENU = {v: i for (i, v) in enumerate('Burger Fries Chicken Pizza Sandwich Onionrings Milkshake Coke'.split())}
REG_CMD = re.compile('|'.join(MENU), flags=re.I)

def get_order(order):
	return ' '.join(sorted(map(str.title, REG_CMD.findall(order)), key=MENU.get))


from re import findall

def get_order(order):
	menu = ['Burger', 'Fries', 'Chicken', 'Pizza', 'Sandwich', 'Onionrings', 'Milkshake', 'Coke']
	return ' '.join(filter(None, (' '.join(findall(item.lower(), order)).title() for item in menu)))


def get_order(order):
	(menu, Menu) = (['burger', 'fries', 'chicken', 'pizza', 'sandwich', 'onionrings', 'milkshake', 'coke'], ['Burger', 'Fries', 'Chicken', 'Pizza', 'Sandwich', 'Onionrings', 'Milkshake', 'Coke'])
	(str, num) = ('', 0)
	(lst, lst2, result) = ([], [], [])
	for letter in order:
		str += letter
		if str in menu:
			lst.append(str)
			str = ''
	for word in lst:
		lst2.append(word.capitalize())
	for counter in range(0, 8):
		for word in lst2:
			if word == Menu[counter]:
				result.append(word)
	return ' '.join(result)


import re
MENU = ['burger', 'fries', 'chicken', 'pizza', 'sandwich', 'onionrings', 'milkshake', 'coke']

def get_order(order):
	res = []
	for item in MENU:
		res.extend(re.findall(item, order))
	return ' '.join([item.capitalize() for item in res])


get_order = lambda order: ''.join([item * order.count(item[1:].lower()) for item in ' Burger, Fries, Chicken, Pizza, Sandwich, Onionrings, Milkshake, Coke'.split(',')])[1:]


def get_order(order):
	menu = ['Burger', 'Fries', 'Chicken', 'Pizza', 'Sandwich', 'Onionrings', 'Milkshake', 'Coke']
	return ''.join([(item + ' ') * order.count(item.lower()) for item in menu]).strip()


def get_order(order):
	word = ''
	list = ['Burger', 'Fries', 'Chicken', 'Pizza', 'Sandwich', 'Onionrings', 'Milkshake', 'Coke']
	for i in list:
		word = word + (' ' + i) * order.count(i.lower())
	return word.strip()