### HackerRank Python Solution - Built-Ins - ginortS

• You are given a string S. S contains alphanumeric characters only.
• Your task is to sort the string S in the following manner:
• All sorted lowercase letters are ahead of uppercase letters.
• All sorted uppercase letters are ahead of digits.
• All sorted odd digits are ahead of sorted even digits.
Input Format:
• A single line of input contains the string S.
Constraints:
• 0 < len(S) < 1000
Output Format:
• Output the sorted string S.
Sample Input:

``````Sorting1234
``````
Sample Output:

``````ginortS1324
``````
Solution:

``````s = input()
upper, lower,odd, even  = [], [], [], []

for char in s:
if char.isnumeric():
if int(char)%2 == 0:
even.append(char)
else:
odd.append(char)
else:
if char.isupper():
upper.append(char)
else:
lower.append(char)

print(''.join(sorted(lower))+''.join(sorted(upper))+''.join(sorted(odd))+''.join(sorted(even)))
``````
Disclaimer: The problem statement is given by hackerrank.com but the solution is generated by the Geek4Tutorial admin. If there is any concern regarding this post or website, please contact us using the contact form. Thank you!

## You might also like

### Deploy your Django web app to Azure Web App using App Service - F1 free plan

In this post, we will look at how we can deploy our Django app using the Microsoft Azure app service - a free plan. You need an Azure accoun...