J 48 Bytes#41 35 Bytes
(u:65+i.26)&([\:[:#[#/.~[~@,((e.~#])toupper))
Demo:
i=: 'This is a test to see whether this is still working'
(u:65+i.26)&([\:[:#[#/.~[~@,((e.~#])toupper)) i
STIEHLORWAGKNBCDFJMPQUVXYZ
Explanation:
(u:65+i.26) & ( [ \: [: #/.~ [ ~@, ((e.~#]) toupper) )
ABCDE... | | | | uppercase the right argument
| | | \copy from right only member from left
| | \append the left argument
| \ Afterwards Count apperances of each letter
\ Sort the left according to the appearances
The key is to append the left array, such that all letters are available, and already in order. A funny consequence of using a noun as third tine to the fork is that it works as verb as well as as phrase.