## digitalmars.D.bugs - [Issue 9878] New: std.algorithm.cartesianProduct results order

d-bugmail puremagic.com writes:
```http://d.puremagic.com/issues/show_bug.cgi?id=9878

Summary: std.algorithm.cartesianProduct results order
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: minor
Priority: P2
Component: Phobos
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc

--- Comment #0 from bearophile_hugs eml.cc 2013-04-04 19:48:53 PDT ---
This is an example of Python usage of its product() function:

from itertools import product
list(product([0, 1], repeat=3))

[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0),
(1, 1, 1)]

This is a similar usage of Phobos std.algorithm.cartesianProduct:

import std.stdio, std.algorithm, std.string, std.conv, std.array;
void main() {
auto bits = [0, 1];
auto p = cartesianProduct(bits, bits, bits);
p.text.replace("Tuple!(int, int, int)", "").writeln;
}

Its output:

[(0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), (0, 0, 1), (1, 0, 1), (0, 1, 1),
(1, 1, 1)]

I'd like cartesianProduct() to give its results in the same order as Python. If
you see in Python the results are like the binary numbers:

000
001
010
011
100
101
110
111

I think this is a more natural and more useful order.

--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
```
Apr 04 2013
d-bugmail puremagic.com writes:
```http://d.puremagic.com/issues/show_bug.cgi?id=9878

--- Comment #1 from hsteoh quickfur.ath.cx 2013-05-27 19:56:52 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1314

--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
```
May 27 2013
d-bugmail puremagic.com writes:
```http://d.puremagic.com/issues/show_bug.cgi?id=9878

thelastmammoth gmail.com changed:

----------------------------------------------------------------------------
CC|                            |thelastmammoth gmail.com

--- Comment #2 from thelastmammoth gmail.com 2013-05-27 21:28:17 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1314

http://forum.dlang.org/post/mailman.283.1369715080.13711.digitalmars-d puremagic.com
where I suggest to give a template parameter to specify
lexicographic/antilexicographic, along with depth first/breadth first.

--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
```
May 27 2013
d-bugmail puremagic.com writes:
```http://d.puremagic.com/issues/show_bug.cgi?id=9878

--- Comment #3 from bearophile_hugs eml.cc 2013-05-28 02:56:25 PDT ---