Sorting keys before printing notes