Skip to main content
added 414 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50

Test:

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

Another approach using the idea of @kglr:

 MyOrderList[list_List, order_List] := 
 Block[{slist, sorder, ordering, mylist},
 slist := Map[Sort, list];
 ordering := 
 Extract[Map[Ordering@*Ordering, Permutations[order]], {1}];(*@kglr*)
 mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
 Return[mylist];
   ];

Test:

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

Another approach using the idea of @kglr:

 MyOrderList[list_List, order_List] := 
 Block[{slist, sorder, ordering, mylist},
 slist := Map[Sort, list];
 ordering := 
 Extract[Map[Ordering@*Ordering, Permutations[order]], {1}];(*@kglr*)
 mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
 Return[mylist];
   ];

Test:

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

Another approach using the idea of @kglr:

 MyOrderList[list_List, order_List] := 
 Block[{slist, sorder, ordering, mylist},
 slist := Map[Sort, list];
 ordering := 
 Extract[Map[Ordering@*Ordering, Permutations[order]], {1}];(*@kglr*)
 mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
 Return[mylist];
   ];

Test:

MyOrderList[list, {c, a, b}]
(*{{{c, 5}, {a, 1}, {b, 3}}, {{c, 3}, {a, 5}, {b, 1}}, {{c, 1}, 
  {a, 5}, {b, 3}}, {{c, 3}, {a, 1}, {b, 5}}}*)
added 414 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50

Another approach using ideasthe idea of @cvgmt and @kglr:

  MyOrderList[list_List, order_List] := 
  Block[{slist, sorder, ordering, mylist},
  slist := Map[Sort, list];
  ordering := 
  Extract[Permute[Ordering[Sort[order]], Ordering[#]] & /@ 
  Permutations[order], {1}];(*@cvgmt*)
  mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
  Return[mylist];
   ];

Another approach using the idea of @kglr:

 MyOrderList[list_List, order_List] := 
 Block[{slist, sorder, ordering, mylist},
 slist := Map[Sort, list];
 ordering := 
 Extract[Map[Ordering@*Ordering, Permutations[order]], {1}];(*@kglr*)
 mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
 Return[mylist];
   ];

Another approach using ideas of @cvgmt and @kglr:

  MyOrderList[list_List, order_List] := 
  Block[{slist, sorder, ordering, mylist},
  slist := Map[Sort, list];
  ordering := 
  Extract[Permute[Ordering[Sort[order]], Ordering[#]] & /@ 
  Permutations[order], {1}];
  mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
   Return[mylist];
   ];

Another approach using the idea of @cvgmt:

  MyOrderList[list_List, order_List] := 
  Block[{slist, sorder, ordering, mylist},
  slist := Map[Sort, list];
  ordering := 
  Extract[Permute[Ordering[Sort[order]], Ordering[#]] & /@ 
  Permutations[order], {1}];(*@cvgmt*)
  mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
  Return[mylist];
   ];

Another approach using the idea of @kglr:

 MyOrderList[list_List, order_List] := 
 Block[{slist, sorder, ordering, mylist},
 slist := Map[Sort, list];
 ordering := 
 Extract[Map[Ordering@*Ordering, Permutations[order]], {1}];(*@kglr*)
 mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
 Return[mylist];
   ];
added 414 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50

Your problem in general is somewhat complicated for more characters, but I will think a little more about it.Another approach using ideas of @cvgmt and @kglr:

  MyOrderList[list_List, order_List] := 
  Block[{slist, sorder, ordering, mylist},
  slist := Map[Sort, list];
  ordering := 
  Extract[Permute[Ordering[Sort[order]], Ordering[#]] & /@ 
  Permutations[order], {1}];
  mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
   Return[mylist];
   ];

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

Another approach using ideas of @cvgmt and @kglr:

  MyOrderList[list_List, order_List] := 
  Block[{slist, sorder, ordering, mylist},
  slist := Map[Sort, list];
  ordering := 
  Extract[Permute[Ordering[Sort[order]], Ordering[#]] & /@ 
  Permutations[order], {1}];
  mylist := Table[slist[[i]][[ordering]], {i, 1, Length[slist]}];
   Return[mylist];
   ];
deleted 280 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50
Loading
added 39 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50
Loading
deleted 1 character in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50
Loading
added 1635 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50
Loading
deleted 425 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50
Loading
added 540 characters in body
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50
Loading
Source Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50
Loading