printing and sorting keys