sorted data and returned hash