6. Count of Occurrences

If asked in a technical interview, could you write a function that lists the number of occurrences for each word in descending order? For the output, assume your solution makes use of a standard Swift Dictionary or Array of tuple values. Also assume your algorithm does not make use of any built-in Swift sorting functions:

input: 
this is a test of the emergency broadcast system this is only a test dog dog dog
output:
dog 3
a 2
is 2
test 2
this 2
broadcast 1
emergency 1
of 1
only 1
the 1
system 1

Hints

At first glance, this challenge seems relatively straightforward. The idea being one could easily iterate through a list of words in O(n) - linear time and track the number of word occurrences with a standard dictionary. However, difficulty is introduced when sorting the word list. Without using a built-in function, how would you keep the list sorted as new items are being added?