Sort a list by elements of another listOrdered 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

Avoiding estate tax by giving multiple gifts

Is exact Kanji stroke length important?

Proof of work - lottery approach

Short story about space worker geeks who zone out by 'listening' to radiation from stars

Implement the Thanos sorting algorithm

Opposite of a diet

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

Purchasing a ticket for someone else in another country?

How to Reset Passwords on Multiple Websites Easily?

Is this version of a gravity generator feasible?

How do I extract a value from a time formatted value in excel?

What is paid subscription needed for in Mortal Kombat 11?

How easy is it to start Magic from scratch?

What is the best translation for "slot" in the context of multiplayer video games?

Is the destination of a commercial flight important for the pilot?

Gears on left are inverse to gears on right?

Do the temporary hit points from Reckless Abandon stack if I make multiple attacks on my turn?

Fastening aluminum fascia to wooden subfascia

Why Were Madagascar and New Zealand Discovered So Late?

Balance Issues for a Custom Sorcerer Variant

How to be diplomatic in refusing to write code that breaches the privacy of our users

Increase performance creating Mandelbrot set in python

Go Pregnant or Go Home

Integer addition + constant, is it a group?



Sort a list by elements of another list


Ordered 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













7












$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 *)









share|improve this question











$endgroup$











  • $begingroup$
    to be more specific list2should be sorted according to the first column of list1
    $endgroup$
    – M.A.
    5 hours ago










  • $begingroup$
    Is there a better example to show what you want? Doesn't Sort[list2] give the desired output?
    $endgroup$
    – Jason B.
    43 mins ago










  • $begingroup$
    list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...
    $endgroup$
    – Daniel Lichtblau
    30 mins ago















7












$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 *)









share|improve this question











$endgroup$











  • $begingroup$
    to be more specific list2should be sorted according to the first column of list1
    $endgroup$
    – M.A.
    5 hours ago










  • $begingroup$
    Is there a better example to show what you want? Doesn't Sort[list2] give the desired output?
    $endgroup$
    – Jason B.
    43 mins ago










  • $begingroup$
    list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...
    $endgroup$
    – Daniel Lichtblau
    30 mins ago













7












7








7


1



$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 *)









share|improve this question











$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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









MarcoB

37.9k556114




37.9k556114










asked 5 hours ago









M.A.M.A.

795




795











  • $begingroup$
    to be more specific list2should be sorted according to the first column of list1
    $endgroup$
    – M.A.
    5 hours ago










  • $begingroup$
    Is there a better example to show what you want? Doesn't Sort[list2] give the desired output?
    $endgroup$
    – Jason B.
    43 mins ago










  • $begingroup$
    list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...
    $endgroup$
    – Daniel Lichtblau
    30 mins ago
















  • $begingroup$
    to be more specific list2should be sorted according to the first column of list1
    $endgroup$
    – M.A.
    5 hours ago










  • $begingroup$
    Is there a better example to show what you want? Doesn't Sort[list2] give the desired output?
    $endgroup$
    – Jason B.
    43 mins ago










  • $begingroup$
    list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...
    $endgroup$
    – Daniel Lichtblau
    30 mins ago















$begingroup$
to be more specific list2should be sorted according to the first column of list1
$endgroup$
– M.A.
5 hours ago




$begingroup$
to be more specific list2should be sorted according to the first column of list1
$endgroup$
– M.A.
5 hours ago












$begingroup$
Is there a better example to show what you want? Doesn't Sort[list2] give the desired output?
$endgroup$
– Jason B.
43 mins ago




$begingroup$
Is there a better example to show what you want? Doesn't Sort[list2] give the desired output?
$endgroup$
– Jason B.
43 mins ago












$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...
$endgroup$
– Daniel Lichtblau
30 mins ago




$begingroup$
list2[[OrderingBy[list1, -#[[2]] &]]] in the next release...
$endgroup$
– Daniel Lichtblau
30 mins ago










3 Answers
3






active

oldest

votes


















5












$begingroup$

Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]



A, 4, B, 5, C, 1







share|improve this answer











$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 be Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
    $endgroup$
    – Henrik Schumacher
    3 hours ago






  • 1




    $begingroup$
    Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
    $endgroup$
    – MikeY
    3 hours ago


















6












$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







share|improve this answer











$endgroup$












  • $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.
    2 hours ago


















3












$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[PermutationReplace[Range[s], RandomPermutation[s]],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationReplace[Range[s], 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 *)





share|improve this answer











$endgroup$












  • $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
    33 mins ago










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
);



);













draft saved

draft discarded


















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









5












$begingroup$

Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]



A, 4, B, 5, C, 1







share|improve this answer











$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 be Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
    $endgroup$
    – Henrik Schumacher
    3 hours ago






  • 1




    $begingroup$
    Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
    $endgroup$
    – MikeY
    3 hours ago















5












$begingroup$

Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]



A, 4, B, 5, C, 1







share|improve this answer











$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 be Permute[list2, FindPermutation[list2[[All, 1]], list1[[All, 1]]]].
    $endgroup$
    – Henrik Schumacher
    3 hours ago






  • 1




    $begingroup$
    Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
    $endgroup$
    – MikeY
    3 hours ago













5












5








5





$begingroup$

Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]



A, 4, B, 5, C, 1







share|improve this answer











$endgroup$



Permute[list2, FindPermutation[ list2[[All,1]] , list1[[All,1]] ] ]



A, 4, B, 5, C, 1








share|improve this answer














share|improve this answer



share|improve this answer








edited 3 hours ago

























answered 3 hours ago









MikeYMikeY

3,528714




3,528714











  • $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
    3 hours ago






  • 1




    $begingroup$
    Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
    $endgroup$
    – MikeY
    3 hours ago
















  • $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
    3 hours ago






  • 1




    $begingroup$
    Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
    $endgroup$
    – MikeY
    3 hours ago















$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
3 hours ago




$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
3 hours ago




1




1




$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
3 hours ago




$begingroup$
Doh...fixed it. Both ways give the same answer, which leads to sloppy debugging.
$endgroup$
– MikeY
3 hours ago











6












$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







share|improve this answer











$endgroup$












  • $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.
    2 hours ago















6












$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







share|improve this answer











$endgroup$












  • $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.
    2 hours ago













6












6








6





$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







share|improve this answer











$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








share|improve this answer














share|improve this answer



share|improve this answer








edited 3 hours ago

























answered 4 hours ago









Henrik SchumacherHenrik Schumacher

58.1k580160




58.1k580160











  • $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.
    2 hours ago
















  • $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.
    2 hours ago















$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.
2 hours ago




$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.
2 hours ago











3












$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[PermutationReplace[Range[s], RandomPermutation[s]],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationReplace[Range[s], 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 *)





share|improve this answer











$endgroup$












  • $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
    33 mins ago















3












$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[PermutationReplace[Range[s], RandomPermutation[s]],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationReplace[Range[s], 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 *)





share|improve this answer











$endgroup$












  • $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
    33 mins ago













3












3








3





$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[PermutationReplace[Range[s], RandomPermutation[s]],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationReplace[Range[s], 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 *)





share|improve this answer











$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[PermutationReplace[Range[s], RandomPermutation[s]],
RandomInteger[0, 10, s]];
list2 = Transpose[PermutationReplace[Range[s], 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 *)






share|improve this answer














share|improve this answer



share|improve this answer








edited 45 mins ago

























answered 2 hours ago









RomanRoman

3,7151020




3,7151020











  • $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
    33 mins 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
    33 mins 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
33 mins 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
33 mins ago

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Андора Зьмест Гісторыя | Палітыка | Адміністрацыйны падзел | Геаграфія | Эканоміка | Дэмаграфія | Крыніцы | Вонкавыя спасылкі | Навігацыйнае мэню"CIA World Factbook entry: Andorra"."Andorra 2008, Departament d'estadística d'Andorra"Андорарр

J. J. Abrams Índice Traxectoria | Filmografía | Premios | Notas | Véxase tamén | Menú de navegacióne"J.J. Abrams: Biography"Arquivado"'Star Trek' sequel on track"Arquivado"J.J. Abrams Producing Samurai Jack Movie"Arquivado"EXCLUSIVE: J.J. Abrams Goes Into Warp Speed with Star Trek and Beyond"Arquivado"David Semel To Direct Jonah Nolan/J.J. Abrams' CBS Pilot 'Person Of Interest'"Arquivado"Fox orders J.J. Abrams pilot 'Alcatraz'"ArquivadoJ. J. AbramsJ. J. AbramsWorldCat81800131p24091041000XX116709414031616ma11226833654496ID052246713376222X511412nm00091900000 0001 1772 5428no98124254ID0000002883100650044xx0054597000141374297344064w64f2mjx14255303415344

Сэнт-Люіс Вонкавыя спасылкі | Навігацыйнае мэню38°37′38″ пн. ш. 90°11′52″ з. д. / 38.62722° пн. ш. 90.19778° з. д. / 38.62722; -90.1977838°37′38″ пн. ш. 90°11′52″ з. д. / 38.62722° пн. ш. 90.19778° з. д. / 38.62722; -90.19778stlouis-mo.govСэнт-ЛюісAnnual Estimates of the Resident Population for Incorporated Places – U.S. Census Bureau, Population Division