Skip to main content
6 of 10
added 39 characters in body
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50

Something like the following:

Map[Sort[#] &, list]
(*{{{a, 1}, {b, 3}, {c, 5}}, {{a, 5}, {b, 1}, {c, 3}}, {{a, 5}, {b, 3}, {c, 1}}, {{a, 1}, {b, 5}, {c, 3}}}*)

A first approximation:

MyOrderList[list_List, order_?(Positive[#] && Element[#, Integers] &)] := 
Block[{slist, list1, list2, list3, list4, mylist},
slist := Map[Sort, list];
list1 := Extract[Select[Tuples[slist[[1]], Length[slist[[1]]]], 
ContainsAll[#, slist[[1]]] &], order];
list2 := Extract[Select[Tuples[slist[[2]], Length[slist[[2]]]], 
ContainsAll[#, slist[[2]]] &], order];
list3 := Extract[Select[Tuples[slist[[3]], Length[slist[[3]]]], 
ContainsAll[#, slist[[3]]] &], order];
list4 := Extract[Select[Tuples[slist[[4]], Length[slist[[4]]]], 
ContainsAll[#, slist[[4]]] &], order];
mylist := List[list1, list2, list3, list4];
Return[If[order <= 6, mylist, HoldForm[MyOrderList]]];
];

Tests:

MyOrderList[list, 1]
(*{{{a, 1}, {b, 3}, {c, 5}}, {{a, 5}, {b, 1}, {c, 3}}, {{a, 5}, 
  {b, 3}, {c, 1}}, {{a, 1}, {b, 5}, {c, 3}}}*)
MyOrderList[list, 2]
(*{{{a, 1}, {c, 5}, {b, 3}}, {{a, 5}, {c, 3}, {b, 1}}, {{a, 5}, 
  {c, 1}, {b, 3}}, {{a, 1}, {c, 3}, {b, 5}}}*)
MyOrderList[list, 3]
(*{{{b, 3}, {a, 1}, {c, 5}}, {{b, 1}, {a, 5}, {c, 3}}, {{b, 3}, 
  {a, 5}, {c, 1}}, {{b, 5}, {a, 1}, {c, 3}}}*)
MyOrderList[list,4]
(*{{{b, 3}, {c, 5}, {a, 1}}, {{b, 1}, {c, 3}, {a, 5}}, {{b, 3}, 
  {c, 1}, {a, 5}}, {{b, 5}, {c, 3}, {a, 1}}}*)
MyOrderList[list,5]
(*{{{c, 5}, {a, 1}, {b, 3}}, {{c, 3}, {a, 5}, {b, 1}}, {{c, 1}, 
  {a, 5}, {b, 3}}, {{c, 3}, {a, 1}, {b, 5}}}*)
MyOrderList[list,6]
(*{{{c, 5}, {b, 3}, {a, 1}}, {{c, 3}, {b, 1}, {a, 5}}, {{c, 1}, 
  {b, 3}, {a, 5}}, {{c, 3}, {b, 5}, {a, 1}}}*)

Your problem in general is somewhat complicated for more characters, but I will think a little more about it.

E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50