Sign that word 2!
Pyth, 10 bytes
sm@+drd1zG
Try it online: Demonstration
Explanation:
implicit: z = input string
m G map each letter (variable d) of the alphabet to:
+drd1 d + upper(d)
@ z filter z for these two letters
s sum, join to a string
Python 3, 72 70 bytes
s=input()
print("".join(d*(ord(d)&31==c)for c in range(27)for d in s))
Assumes the input consists of only [a-zA-Z]
.
(-2 bytes thanks to @xnor)
Haskell, 51
f s=[x|(a,b)<-zip['a'..'z']['A'..],x<-s,x==a||x==b]
The zip
creates a list of pairs of characters [('a','A'), ...('z','Z')]
. Because of truncation, the second endpoint doesn't need to be specified. For each pair in the list, we take the letters in the input string s
that are either of the two characters in the pair.