hist_sort () function added