sorting with first comes up in array : I want to get an answer ['H','H','A',A]
from the input ['H','A','H','A']

basically sorting based from the char that comes up first.
could someone help me 

Thanks