Refine order function to return a cons-cell instead of a list and add precondition check in order not to die when an empty list is passed to min/max/minmax function