in reply to Sorting a Hash

> how I could go about sorting a hash

you don't seem to sort hashes but hash-refs by entries.

hashes can't be sorted, only their keys, (you'll find myriads of examples in the archives)

> I get the the following output: D1 P5 P2 P3

there are no D1 P5 P2 P3 in your sample data.

In order to understand you better please provide clear code, especially a (little) Data::Dumper dump of your data structure, instead of a C&P of your source.

see also How (not) to ask a question

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

UPDATE

OP updated his node, w/o indication