On 5 February 2016 at 12:04, John Cremona <john.crem...@gmail.com> wrote:
> Understood.  I thought that a total order was implemented for number
> field elements, but looking in the code I could not even find the
> relevant _cmp_ function!

I think it is possible that the clever code people have written to
implement ordering of number field elements when these have an
embedding into RR does nothing at all when there is no real embedding
(true in my example), meaning that there is no sensible python-style
sorting available at all.  If true that would be disastrous.  I (for
one) absolutely need for there to be a well-defined total order for
number field elements, for purposes of sorting uniquely, regardless of
any implementation of  mathematical order.

I know how to provide my own key function for sorting, and will have
to re-implement this since the one I had relied on this incorrect
assumption that number field elements had a total ordering already.

John
>
> John
>
> On 5 February 2016 at 11:49, Nathann Cohen <nathann.co...@gmail.com> wrote:
>> 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.

-- 
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