Given a standard english sentence passed in as a string, write a method that will return a sentence made up of the same words, but sorted by their first letter. However, the method of sorting has a twist to it:
* All words that begin with a lower case letter should be at the beginning of the sorted sentence, and sorted in ascending order.
* All words that begin with an upper case letter should come after that, and should be sorted in descending order.

If a word appears multiple times in the sentence, it should be returned multiple times in the sorted sentence. Any punctuation must be discarded.

## Example

For example, given the input string `"Land of the Old Thirteen! Massachusetts land! land of Vermont and Connecticut!"`, your method should return `"and land land of of the Vermont Thirteen Old Massachusetts Land Connecticut"`. Lower case letters are sorted `a -> l -> l -> o -> o -> t` and upper case letters are sorted `V -> T -> O -> M -> L -> C`.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Sorting

Starter code: def pseudo_sort(st):
	

Solutions:
from string import punctuation
t = str.maketrans('', '', punctuation)

def pseudo_sort(s):
	a = s.translate(t).split()
	b = sorted((x for x in a if x[0].islower()))
	c = sorted((x for x in a if x[0].isupper()), reverse=True)
	return ' '.join(b + c)


from string import punctuation

def pseudo_sort(st):
	capital_list = sorted([word.strip(punctuation) for word in st.split() if word[0].isupper()], reverse=True)
	lower_list = sorted([word.strip(punctuation) for word in st.split() if word[0].islower()])
	return ' '.join(lower_list + capital_list)


def pseudo_sort(s):
	s = ''.join((i for i in s if i.isalpha() or i is ' '))
	a = sorted((i for i in s.split() if i[0].islower()))
	b = sorted((i for i in s.split() if i[0].isupper()), key=lambda x: x.lower(), reverse=True)
	return ' '.join(a + b)


from re import findall

def pseudo_sort(st):
	lows = sorted(findall('\\b[a-z]+\\b', st))
	ups = sorted(findall('[A-Z][A-Za-z]*', st), reverse=True)
	return ' '.join(lows + ups)


def pseudo_sort(st):
	words = st.translate(str.maketrans('', '', '.,:;!?')).split()
	(lower, upper) = ([], [])
	for word in words:
		if word[0].isupper():
			upper.append(word)
		else:
			lower.append(word)
	return ' '.join(sorted(lower) + sorted(upper, reverse=True))


import re

def pseudo_sort(st):
	lower_case_words = re.findall('\\b[a-z]\\w*', st)
	upper_case_words = re.findall('\\b[A-Z]\\w*', st)
	lower_case_words.sort()
	upper_case_words.sort(reverse=True)
	return ' '.join(lower_case_words + upper_case_words)


import re

def pseudo_sort(st):
	(st, upper, lower) = (re.sub('[^ \\w]', '', st).split(), [], [])
	for i in st:
		if i[0].islower():
			lower.append(i)
		else:
			upper.append(i)
	return ' '.join(sorted(lower) + sorted(upper)[::-1])


def pseudo_sort(stg):
	(lowers, uppers) = ([], [])
	for word in ''.join((char for char in stg if char.isalpha() or char == ' ')).split():
		(lowers if word[0].islower() else uppers).append(word)
	return ' '.join(sorted(lowers) + sorted(uppers)[::-1])


def pseudo_sort(st):
	st = st.replace(',', '')
	st = st.replace('!', '')
	st = st.replace('.', '')
	st = st.replace(':', '')
	st = st.replace(';', '')
	st = st.replace('?', '')
	st = st.split()
	lis1 = [i for i in st if i.islower() == True]
	lis2 = [i for i in st if i[0].isupper() == True]
	lis1.sort(reverse=False)
	lis2.sort(reverse=True)
	return ' '.join(lis1 + lis2)


import re
from functools import cmp_to_key

def compare(a, b):
	cmp1 = a[0].isupper() - b[0].isupper()
	cmp2 = (a < b) - (a > b)
	return cmp1 or cmp2 * (-1 if a[0].islower() else 1)

def pseudo_sort(st):
	return ' '.join(sorted(re.findall('\\w+', st), key=cmp_to_key(compare)))