I have an array of number field elements:

sage: [x for x in bounds]
[4*x - 1, 10/3*x - 4/3, 4*x - 1, 2*x - 1, 4*x - 1, 4*x - 1, 0]

They belong to a field that has an embedding, and I would like to sort
them according to their real values.

I can do it using float conversions:

sage: sorted(float(x) for x in bounds)
[-0.26794919243112281, -0.11324865405187112, 0.0, 0.46410161513775439,
0.46410161513775439, 0.46410161513775439, 0.46410161513775439]

Or:

sage: sorted(bounds, key = lambda x: float(x))
[2*x - 1, 10/3*x - 4/3, 0, 4*x - 1, 4*x - 1, 4*x - 1, 4*x - 1]

But, this is a bit messy, and could be imprecise.

It would be good if I could just do:

sage: sorted(bounds)
[4*x - 1, 10/3*x - 4/3, 4*x - 1, 2*x - 1, 4*x - 1, 4*x - 1, 0]

But this doesn't appear to work! Is there a way to do this?  Thanks,

Emil

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to