Hello coders, today we are going to solve ginorts HackerRank Solution in Python.
You are given a string S.
S contains alphanumeric characters only.
Your task is to sort the string 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.
A single line of input contains the string S.
- 0 < len(S) < 1000
Output the sorted string S.
Solution – ginortS in Python
# Enter your code here. Read input from STDIN. Print output to STDOUT print(*sorted(input(), key=lambda c: (c.isdigit() - c.islower(), c in '02468', c)), sep='')
Disclaimer: The above Problem (ginorts) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.