converting sort to hash