def sort_dict(dictionary, rev = True): l = list(dictionary.items()) l.sort(reverse = rev) a = [item[1] for item in l] z = '' for x in a: z = z + str(x) return(z)