revised sort function

sort f’s for plotting