Update the code to use sort preference from user object