implement dictionary sorting