How can I sort the keys in descending order by their value and if two keys have the same quantity, I must print them in alphabetical order. I know that probably a user function must be created, but i was not able to learn how to make those.
Array:
array(3) {
  ["motes"]=>
  int(3)
  ["shards"]=>
  int(5)
  ["fragments"]=>
  int(5)
}
Output:
fragments: 5
shards: 5
motes: 3
 
    