sort and hashify