in my case sorted() does not sort that list:
sage: K.<zeta8> = CyclotomicField(8)
sage: g=GL(2,3)
sage: sorted([x.values() for x in g.irreducible_characters()])
[[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, -1, -1, -1], [2, -1, 2, -1,
2, 0, 0, 0], [2, 1, -2, -1, 0, -zeta8^3 - zeta8, zeta8^3 + zeta8, 0],
[2, 1, -2, -1, 0, zeta8^3 + zeta8, -zeta8^3 - zeta8, 0], [3, 0, 3, 0,
-1, 1, 1, -1], [3, 0, 3, 0, -1, -1, -1, 1], [4, -1, -4, 1, 0, 0, 0,
0]]

(no matter whether or not I do K.<zeta8> = CyclotomicField(8))

Dima

On Jan 26, 7:08 pm, Alex Ghitza <aghi...@gmail.com> wrote:
> On Tue, 26 Jan 2010 02:00:34 -0800 (PST), Dima Pasechnik <dimp...@gmail.com> 
> wrote:
> > yes, this works for numerical lists, but not for e.g.
> > [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, -1, -1, -1], [2, -1, 2, -1,
> > 2, 0, 0, 0], [2, 1, -2, -1, 0, -zeta8^3 - zeta8, zeta8^3 + zeta8, 0],
> > [2, 1, -2, -1, 0, zeta8^3 + zeta8, -zeta8^3 - zeta8, 0], [3, 0, 3, 0,
> > -1, 1, 1, -1], [3, 0, 3, 0, -1, -1, -1, 1], [4, -1, -4, 1, 0, 0, 0,
> > 0]]
>
> > (sorted does not like mixing zeta (string(?)) with numbers,
> > apparently)
>
> Here is what I get:
>
> sage: K.<zeta8> = CyclotomicField(8)
> sage: lst =
> [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, -1, -1, -1],
>  [2, -1, 2, -1, 2, 0, 0, 0], [2, 1, -2, -1, 0, -zeta8^3 - zeta8, zeta8^3 + 
> zeta8, 0],
>  [2, 1, -2, -1, 0, zeta8^3 + zeta8, -zeta8^3 - zeta8, 0], [3, 0, 3, 0, -1, 1, 
> 1, -1],
>  [3, 0, 3, 0, -1, -1, -1, 1], [4, -1, -4, 1, 0, 0, 0, 0]]
> sage: sorted(lst)
> [[1, 1, 1, 1, 1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1],
>  [2, -1, 2, -1, 2, 0, 0, 0], [2, 1, -2, -1, 0, -zeta8^3 - zeta8, zeta8^3 + 
> zeta8, 0],
>  [2, 1, -2, -1, 0, zeta8^3 + zeta8, -zeta8^3 - zeta8, 0], [3, 0, 3, 0, -1, 
> -1, -1, 1],
>  [3, 0, 3, 0, -1, 1, 1, -1], [4, -1, -4, 1, 0, 0, 0, 0]]
>
> I'm not sure what you mean by "works" or "does not work".  The list gets
> sorted by Python.  This ordering does not magically acquire mathematical
> naturality that it did not have before, we just get a list that will now
> be the same no matter what version of Sage, GAP, C compiler, etc. is
> used.  The only way you might be able to get a different-looking result
> now is if you change the underlying comparison function, which is not
> something that happens very often at all.
>
> So the point of sorted() is not necessarily that the resulting list will
> look sorted to the human eye, but that computers will reliably always
> get the same answer.
>
> Best,
> Alex
>
> --
> Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne
> -- Australia --http://www.ms.unimelb.edu.au/~aghitza/

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

Reply via email to