Sort a list by elements of another list The Next CEO of Stack OverflowOrdered indices of a multiple product or sumImporting, sorting and exporting listsThe efficiency compare between Flatten[#, 1] & and Join @@ # &Lexicographic ordering of lists-of-lists?Problem with Custom Sort/Split/GatherApplying multiple functions to a single column in a tableList of (sub-)lists - query sub-lists by names?Find positions in which list elements are equalHow can I check if elements between lists are equal?comparing lists of strings
What size rim is OK?
ls Ordering[Ordering[list]] optimal?
Why didn't Khan get resurrected in the Genesis Explosion?
How can I open an app using Terminal?
Can the Reverse Gravity spell affect the Meteor Swarm spell?
Does it take more energy to get to Venus or to Mars?
MAZDA 3 2006 (UK) - poor acceleration then takes off at 3250 revs
% symbol leads to superlong (forever?) compilations
What is the meaning of "rider"?
Customer Requests (Sometimes) Drive Me Bonkers!
Anatomically Correct Strange Women In Ponds Distributing Swords
How to make a software documentation "officially" citable?
Inappropriate reference requests from Journal reviewers
What happens if you roll doubles 3 times then land on "Go to jail?"
Why is Miller's case titled R (Miller)?
What is meant by a M next to a roman numeral?
How do we know the LHC results are robust?
What makes a siege story/plot interesting?
Anatomically Correct Mesopelagic Aves
Opposite of a diet
Removing read access from a file
Under what conditions does the function C = f(A,B) satisfy H(C|A) = H(B)?
Is a stroke of luck acceptable after a series of unfavorable events?
Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?
Sort a list by elements of another list
The Next CEO of Stack OverflowOrdered indices of a multiple product or sumImporting, sorting and exporting listsThe efficiency compare between Flatten[#, 1] & and Join @@ # &Lexicographic ordering of lists-of-lists?Problem with Custom Sort/Split/GatherApplying multiple functions to a single column in a tableList of (sub-)lists - query sub-lists by names?Find positions in which list elements are equalHow can I check if elements between lists are equal?comparing lists of strings
$begingroup$
I know there are a plenty of other questions here which appear to be similar, however I did not found anything which could give me a hint.
I have two lists:
list1 = A, 12, B, 10, C, 4; (*ordered according to the second column*)
list2 = B, 5, A, 4, C, 1; (*ordered according to the second column*)
Now I want to sort list2according to the list1-order so the output should be:
(* A, 4, B, 5, C, 1 *)
list-manipulation sorting
$endgroup$
add a comment |
$begingroup$
I know there are a plenty of other questions here which appear to be similar, however I did not found anything which could give me a hint.
I have two lists:
list1 = A, 12, B, 10, C, 4; (*ordered according to the second column*)
list2 = B, 5, A, 4, C, 1; (*ordered according to the second column*)
Now I want to sort list2according to the list1-order so the output should be:
(* A, 4, B, 5, C, 1 *)
list-manipulation sorting
$endgroup$
$begingroup$
to be more specificlist2should be sorted according to the first column oflist1
$endgroup$
– M.A.
yesterday
1
$begingroup$
Is there a better example to show what you want? Doesn'tSort[list2]give the desired output?
$endgroup$
– Jason B.
22 hours ago
4
$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]]in the next release...
$endgroup$
– Daniel Lichtblau
22 hours ago
add a comment |
$begingroup$
I know there are a plenty of other questions here which appear to be similar, however I did not found anything which could give me a hint.
I have two lists:
list1 = A, 12, B, 10, C, 4; (*ordered according to the second column*)
list2 = B, 5, A, 4, C, 1; (*ordered according to the second column*)
Now I want to sort list2according to the list1-order so the output should be:
(* A, 4, B, 5, C, 1 *)
list-manipulation sorting
$endgroup$
I know there are a plenty of other questions here which appear to be similar, however I did not found anything which could give me a hint.
I have two lists:
list1 = A, 12, B, 10, C, 4; (*ordered according to the second column*)
list2 = B, 5, A, 4, C, 1; (*ordered according to the second column*)
Now I want to sort list2according to the list1-order so the output should be:
(* A, 4, B, 5, C, 1 *)
list-manipulation sorting
list-manipulation sorting
edited yesterday
MarcoB
38k556114
38k556114
asked yesterday
M.A.M.A.
896
896
$begingroup$
to be more specificlist2should be sorted according to the first column oflist1
$endgroup$
– M.A.
yesterday
1
$begingroup$
Is there a better example to show what you want? Doesn'tSort[list2]give the desired output?
$endgroup$
– Jason B.
22 hours ago
4
$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]]in the next release...
$endgroup$
– Daniel Lichtblau
22 hours ago
add a comment |
$begingroup$
to be more specificlist2should be sorted according to the first column oflist1
$endgroup$
– M.A.
yesterday
1
$begingroup$
Is there a better example to show what you want? Doesn'tSort[list2]give the desired output?
$endgroup$
– Jason B.
22 hours ago
4
$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]]in the next release...
$endgroup$
– Daniel Lichtblau
22 hours ago
$begingroup$
to be more specific
list2should be sorted according to the first column of list1$endgroup$
– M.A.
yesterday
$begingroup$
to be more specific
list2should be sorted according to the first column of list1$endgroup$
– M.A.
yesterday
1
1
$begingroup$
Is there a better example to show what you want? Doesn't
Sort[list2] give the desired output?$endgroup$
– Jason B.
22 hours ago
$begingroup$
Is there a better example to show what you want? Doesn't
Sort[list2] give the desired output?$endgroup$
– Jason B.
22 hours ago
4
4
$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...$endgroup$
– Daniel Lichtblau
22 hours ago
$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...$endgroup$
– Daniel Lichtblau
22 hours ago
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]
A, 4, B, 5, C, 1
$endgroup$
$begingroup$
Actually, I like your solution much better than mine. By the way, when I found out that my former solution was incorrect, I also realized that your solution should better bePermute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
$endgroup$
– Henrik Schumacher
yesterday
1
$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
yesterday
add a comment |
$begingroup$
list1 = A, 12, B, 10, C, 4, D, 2;
list2 = A, 4, D, 11, B, 5, C, 1;
idx = Lookup[
AssociationThread[list1[[All, 1]] -> Range[Length[list1]]],
list2[[All, 1]]
];
result = list2;
result[[idx]] = list2;
result
A, 4, B, 5, C, 1, D, 11
$endgroup$
$begingroup$
works well with the example lists. However, something goes wrong when I use other lists with Strings in the first columns instead ofA,BandC....
$endgroup$
– M.A.
yesterday
add a comment |
$begingroup$
ugly but fast:
list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]
A, 4, B, 5, C, 1
even faster:
result = list2;
result[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
result
A, 4, B, 5, C, 1
benchmarks
s = 10^7;
list1 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
(* my first solution *)
result1 = list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]; //AbsoluteTiming//First
(* 8.6416 *)
(* my second solution *)
result2 = Module[L,
L = list2;
L[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
L]; //AbsoluteTiming//First
(* 6.89593 *)
(* MikeY's solution *)
result3 = Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]]; //AbsoluteTiming//First
(* 15.808 *)
(* Henrik Schumacher's solution *)
result4 = Module[idx, L,
idx = Lookup[AssociationThread[list1[[All, 1]] -> Range[Length[list1]]], list2[[All, 1]]];
L = list2;
L[[idx]] = list2;
L]; //AbsoluteTiming//First
(* 31.7412 *)
(* make sure all methods agree *)
result1 == result2 == result3 == result4
(* True *)
$endgroup$
$begingroup$
Thanks for the benchmark. I started down theOrderingroad, but went for parsimony of expression. Mild bummer that it is at least twice as slow as the best method.
$endgroup$
– MikeY
22 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194061%2fsort-a-list-by-elements-of-another-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]
A, 4, B, 5, C, 1
$endgroup$
$begingroup$
Actually, I like your solution much better than mine. By the way, when I found out that my former solution was incorrect, I also realized that your solution should better bePermute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
$endgroup$
– Henrik Schumacher
yesterday
1
$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
yesterday
add a comment |
$begingroup$
Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]
A, 4, B, 5, C, 1
$endgroup$
$begingroup$
Actually, I like your solution much better than mine. By the way, when I found out that my former solution was incorrect, I also realized that your solution should better bePermute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
$endgroup$
– Henrik Schumacher
yesterday
1
$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
yesterday
add a comment |
$begingroup$
Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]
A, 4, B, 5, C, 1
$endgroup$
Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]
A, 4, B, 5, C, 1
edited yesterday
answered yesterday
MikeYMikeY
3,548714
3,548714
$begingroup$
Actually, I like your solution much better than mine. By the way, when I found out that my former solution was incorrect, I also realized that your solution should better bePermute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
$endgroup$
– Henrik Schumacher
yesterday
1
$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
yesterday
add a comment |
$begingroup$
Actually, I like your solution much better than mine. By the way, when I found out that my former solution was incorrect, I also realized that your solution should better bePermute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
$endgroup$
– Henrik Schumacher
yesterday
1
$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
yesterday
$begingroup$
Actually, I like your solution much better than mine. By the way, when I found out that my former solution was incorrect, I also realized that your solution should better be
Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].$endgroup$
– Henrik Schumacher
yesterday
$begingroup$
Actually, I like your solution much better than mine. By the way, when I found out that my former solution was incorrect, I also realized that your solution should better be
Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].$endgroup$
– Henrik Schumacher
yesterday
1
1
$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
yesterday
$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
yesterday
add a comment |
$begingroup$
list1 = A, 12, B, 10, C, 4, D, 2;
list2 = A, 4, D, 11, B, 5, C, 1;
idx = Lookup[
AssociationThread[list1[[All, 1]] -> Range[Length[list1]]],
list2[[All, 1]]
];
result = list2;
result[[idx]] = list2;
result
A, 4, B, 5, C, 1, D, 11
$endgroup$
$begingroup$
works well with the example lists. However, something goes wrong when I use other lists with Strings in the first columns instead ofA,BandC....
$endgroup$
– M.A.
yesterday
add a comment |
$begingroup$
list1 = A, 12, B, 10, C, 4, D, 2;
list2 = A, 4, D, 11, B, 5, C, 1;
idx = Lookup[
AssociationThread[list1[[All, 1]] -> Range[Length[list1]]],
list2[[All, 1]]
];
result = list2;
result[[idx]] = list2;
result
A, 4, B, 5, C, 1, D, 11
$endgroup$
$begingroup$
works well with the example lists. However, something goes wrong when I use other lists with Strings in the first columns instead ofA,BandC....
$endgroup$
– M.A.
yesterday
add a comment |
$begingroup$
list1 = A, 12, B, 10, C, 4, D, 2;
list2 = A, 4, D, 11, B, 5, C, 1;
idx = Lookup[
AssociationThread[list1[[All, 1]] -> Range[Length[list1]]],
list2[[All, 1]]
];
result = list2;
result[[idx]] = list2;
result
A, 4, B, 5, C, 1, D, 11
$endgroup$
list1 = A, 12, B, 10, C, 4, D, 2;
list2 = A, 4, D, 11, B, 5, C, 1;
idx = Lookup[
AssociationThread[list1[[All, 1]] -> Range[Length[list1]]],
list2[[All, 1]]
];
result = list2;
result[[idx]] = list2;
result
A, 4, B, 5, C, 1, D, 11
edited yesterday
answered yesterday
Henrik SchumacherHenrik Schumacher
58.3k580160
58.3k580160
$begingroup$
works well with the example lists. However, something goes wrong when I use other lists with Strings in the first columns instead ofA,BandC....
$endgroup$
– M.A.
yesterday
add a comment |
$begingroup$
works well with the example lists. However, something goes wrong when I use other lists with Strings in the first columns instead ofA,BandC....
$endgroup$
– M.A.
yesterday
$begingroup$
works well with the example lists. However, something goes wrong when I use other lists with Strings in the first columns instead of
A, Band C....$endgroup$
– M.A.
yesterday
$begingroup$
works well with the example lists. However, something goes wrong when I use other lists with Strings in the first columns instead of
A, Band C....$endgroup$
– M.A.
yesterday
add a comment |
$begingroup$
ugly but fast:
list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]
A, 4, B, 5, C, 1
even faster:
result = list2;
result[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
result
A, 4, B, 5, C, 1
benchmarks
s = 10^7;
list1 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
(* my first solution *)
result1 = list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]; //AbsoluteTiming//First
(* 8.6416 *)
(* my second solution *)
result2 = Module[L,
L = list2;
L[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
L]; //AbsoluteTiming//First
(* 6.89593 *)
(* MikeY's solution *)
result3 = Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]]; //AbsoluteTiming//First
(* 15.808 *)
(* Henrik Schumacher's solution *)
result4 = Module[idx, L,
idx = Lookup[AssociationThread[list1[[All, 1]] -> Range[Length[list1]]], list2[[All, 1]]];
L = list2;
L[[idx]] = list2;
L]; //AbsoluteTiming//First
(* 31.7412 *)
(* make sure all methods agree *)
result1 == result2 == result3 == result4
(* True *)
$endgroup$
$begingroup$
Thanks for the benchmark. I started down theOrderingroad, but went for parsimony of expression. Mild bummer that it is at least twice as slow as the best method.
$endgroup$
– MikeY
22 hours ago
add a comment |
$begingroup$
ugly but fast:
list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]
A, 4, B, 5, C, 1
even faster:
result = list2;
result[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
result
A, 4, B, 5, C, 1
benchmarks
s = 10^7;
list1 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
(* my first solution *)
result1 = list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]; //AbsoluteTiming//First
(* 8.6416 *)
(* my second solution *)
result2 = Module[L,
L = list2;
L[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
L]; //AbsoluteTiming//First
(* 6.89593 *)
(* MikeY's solution *)
result3 = Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]]; //AbsoluteTiming//First
(* 15.808 *)
(* Henrik Schumacher's solution *)
result4 = Module[idx, L,
idx = Lookup[AssociationThread[list1[[All, 1]] -> Range[Length[list1]]], list2[[All, 1]]];
L = list2;
L[[idx]] = list2;
L]; //AbsoluteTiming//First
(* 31.7412 *)
(* make sure all methods agree *)
result1 == result2 == result3 == result4
(* True *)
$endgroup$
$begingroup$
Thanks for the benchmark. I started down theOrderingroad, but went for parsimony of expression. Mild bummer that it is at least twice as slow as the best method.
$endgroup$
– MikeY
22 hours ago
add a comment |
$begingroup$
ugly but fast:
list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]
A, 4, B, 5, C, 1
even faster:
result = list2;
result[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
result
A, 4, B, 5, C, 1
benchmarks
s = 10^7;
list1 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
(* my first solution *)
result1 = list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]; //AbsoluteTiming//First
(* 8.6416 *)
(* my second solution *)
result2 = Module[L,
L = list2;
L[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
L]; //AbsoluteTiming//First
(* 6.89593 *)
(* MikeY's solution *)
result3 = Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]]; //AbsoluteTiming//First
(* 15.808 *)
(* Henrik Schumacher's solution *)
result4 = Module[idx, L,
idx = Lookup[AssociationThread[list1[[All, 1]] -> Range[Length[list1]]], list2[[All, 1]]];
L = list2;
L[[idx]] = list2;
L]; //AbsoluteTiming//First
(* 31.7412 *)
(* make sure all methods agree *)
result1 == result2 == result3 == result4
(* True *)
$endgroup$
ugly but fast:
list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]
A, 4, B, 5, C, 1
even faster:
result = list2;
result[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
result
A, 4, B, 5, C, 1
benchmarks
s = 10^7;
list1 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationList@RandomPermutation[s],
RandomInteger[0, 10, s]];
(* my first solution *)
result1 = list2[[Ordering[list2[[All, 1]]][[Ordering[Ordering[list1[[All, 1]]]]]]]]; //AbsoluteTiming//First
(* 8.6416 *)
(* my second solution *)
result2 = Module[L,
L = list2;
L[[Ordering[list1[[All, 1]]]]] = SortBy[list2, First];
L]; //AbsoluteTiming//First
(* 6.89593 *)
(* MikeY's solution *)
result3 = Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]]; //AbsoluteTiming//First
(* 15.808 *)
(* Henrik Schumacher's solution *)
result4 = Module[idx, L,
idx = Lookup[AssociationThread[list1[[All, 1]] -> Range[Length[list1]]], list2[[All, 1]]];
L = list2;
L[[idx]] = list2;
L]; //AbsoluteTiming//First
(* 31.7412 *)
(* make sure all methods agree *)
result1 == result2 == result3 == result4
(* True *)
edited 9 hours ago
answered yesterday
RomanRoman
3,8501020
3,8501020
$begingroup$
Thanks for the benchmark. I started down theOrderingroad, but went for parsimony of expression. Mild bummer that it is at least twice as slow as the best method.
$endgroup$
– MikeY
22 hours ago
add a comment |
$begingroup$
Thanks for the benchmark. I started down theOrderingroad, but went for parsimony of expression. Mild bummer that it is at least twice as slow as the best method.
$endgroup$
– MikeY
22 hours ago
$begingroup$
Thanks for the benchmark. I started down the
Ordering road, but went for parsimony of expression. Mild bummer that it is at least twice as slow as the best method.$endgroup$
– MikeY
22 hours ago
$begingroup$
Thanks for the benchmark. I started down the
Ordering road, but went for parsimony of expression. Mild bummer that it is at least twice as slow as the best method.$endgroup$
– MikeY
22 hours ago
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194061%2fsort-a-list-by-elements-of-another-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
to be more specific
list2should be sorted according to the first column oflist1$endgroup$
– M.A.
yesterday
1
$begingroup$
Is there a better example to show what you want? Doesn't
Sort[list2]give the desired output?$endgroup$
– Jason B.
22 hours ago
4
$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]]in the next release...$endgroup$
– Daniel Lichtblau
22 hours ago