Description: A variant on lexicographic order, which sorts first by some function of
the base set, and then by a "backup" well-ordering when the function
value is equal on both elements. (Contributed by Mario Carneiro, 10-Mar-2013)(Revised by Mario Carneiro, 18-Nov-2014)