tweety,
This question looks remarkably similar to another node you posted very recently, how do i sort hash values?. It looks like cdarke, shmem, and johngg gave you good looking answers for that particular question, which really looks like a simplified case of this question. Update: as I do a little more reading, I see this new "question" is nothing more than a re-posted re-wording of your original question.
What have you done to try to get from your previous step to this step? We're not going to write your program for you.
As prasadbabu has previously recommended, please see How (Not) To Ask A Question.
--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; =
qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
| [reply] [d/l] |