1 | initial version |

All you need to know is how to use list comprehensions in Python:

```
sage: def f(n):
....: P = Permutations(n)
....: return [[p,p.reduced_word_lexmin()] for p in P]
....:
sage: f(2)
[[[1, 2], []], [[2, 1], [1]]]
sage: f(3)
[[[1, 2, 3], []],
[[1, 3, 2], [2]],
[[2, 1, 3], [1]],
[[2, 3, 1], [1, 2]],
[[3, 1, 2], [2, 1]],
[[3, 2, 1], [1, 2, 1]]]
```

Do the following if you need everything to be of type list:

```
sage: def f(n):
....: P = Permutations(n)
....: return [[list(p),p.reduced_word_lexmin()] for p in P]
```

2 | No.2 Revision |

All you need to know is how to use list comprehensions in Python:

```
sage: def f(n):
....: P = Permutations(n)
....: return [[p,p.reduced_word_lexmin()] for p in
```~~P]
~~P if not p.is_one()]
....:
sage: f(2)
~~[[[1, 2], []], [[2, ~~[[[2, 1], [1]]]
sage: f(3)
[[[1, ~~2, 3], []],
[[1, ~~3, 2], [2]],
[[2, 1, 3], [1]],
[[2, 3, 1], [1, 2]],
[[3, 1, 2], [2, 1]],
[[3, 2, 1], [1, 2, 1]]]

Do the following if you need everything to be of type list:

```
sage: def f(n):
....: P = Permutations(n)
....: return [[list(p),p.reduced_word_lexmin()] for p in
```~~P]
~~P if not p.is_one()]

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.