Rebol, 149149, 146 bytes
f: func[s][l: charset[#"a"- #"z"#"A"- #"Z"]to-string#"Z"]rejoin sort/skip collect[parse sort s[any[copy t[copy o l any o](keep length? t keep last t)| skip]]]2]
Ungolfed:
f: func [s] [
l: charset[#"a" - #"z" #"A" - #"Z"]
to-stringrejoin sort/skip collect [
parse sort s [
any [
copy t [copy o l any o] (keep length? t keep last t)
| skip
]
]
] 2
]
Example usage in Rebol console:
>> f "Kitkat Tango"
== "1g1i1n1o2a2k3T"
>> f "Database Partitions Task"
== "1b1D1e1k1n1o1P1r2i3s4T5a"
>> f "12$*34^!"
== ""