Did you notice that every new line you read from your INPUT file, you initialize the 'hash table' ? This way you'll never be able to sort, since at any given time you have one value in the hash.
Secondly you might want to take the 'foreach' loop outside of the 'while loop'. Tried it out and it works, all sorted.