If the default comparison on your objects is not a total order there
is no guarantee that the output of a sorting algorithm (name any that
you know) will give you a unique output.

    sage: sorted([{1,2},{3,4}])
    [{1, 2}, {3, 4}]
    sage: sorted([{3,4},{1,2}])
    [{3, 4}, {1, 2}]

Which comes from:

    sage: {3,4} < {1,2}
    False
    sage: {3,4} > {1,2}
    False

Nathann


On 5 February 2016 at 11:39, John Cremona <john.crem...@gmail.com> wrote:
> I have two lists of 6 (relative) number field elements:  they are the
> same up to a permutation, as revealed by turning each into a set, but
> the do not sort to the same list!
>
> sage: type(L1)
> <type 'list'>
> sage: type(L2)
> <type 'list'>
> sage: type(L1[0])
> <type 
> 'sage.rings.number_field.number_field_element.NumberFieldElement_relative'>
> sage: type(L2[0])
> <type 
> 'sage.rings.number_field.number_field_element.NumberFieldElement_relative'>
> sage: len(L1)==len(L2)==6
> True
>
> sage: L1==L2
> False
> sage: set(L1)==set(L2)
> True
> sage: sorted(L1)==sorted(L2)
> False
>
> This is causing a doctest to fail randomly, since in the code I apply
> a sort function to such lists and the output is not always the same.
> (See #19229, where one patchbot is happy but another is not;  none of
> the changes in that ticket affect the relevant code at all.)
>
> John
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to