Add function to create ordered factors using a numeric function