Some fixes to sort that was not working right, but still does not implement last remembered sort at all.