-
Notifications
You must be signed in to change notification settings - Fork 1
/
ginortS
49 lines (38 loc) · 908 Bytes
/
ginortS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
You are given a string .
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.
Input Format
A single line of input contains the string .
Constraints
Output Format
Output the sorted string .
Sample Input
Sorting1234
Sample Output
ginortS1324
////////////////////////////////////////////////////CODE BELOW/////////////////////////////////////////////////////
q=input()
p=list(q)
l=[]
k=[]
j=[]
m=[]
m.sort()
for i in p:
if i.isupper()==True:
l.append(i)
elif i.islower()==True:
k.append(i)
elif i.isdigit()==True:
if int(i)%2==0:
j.append(i)
else:
m.append(i)
l.sort()
k.sort()
j.sort()
m.sort()
print(''.join(k+l+m+j))