I have the following two lists:
ids = {5, 11, 17, 24, 31, 37, 40, 39, 38, 33, 32, 25}
values = {0.0351563, 0.131836, 0.086792, 0.0637894, 0.065752, 0.191388, 0.063796, 0.173784, 0.0503769, 0.0875244, 0.0146484, 0.0351563}
where entries in values correspond to entries in ids.
I now wish to sort ids in ascending order while maintaining the correspondence to values, such that elements in values must be changed according to the changes made to ids.
How can that be achieved?
values[[Ordering@ids]]
andSortBy[Transpose[{ids, values}], First] == Transpose[{Sort@ids, values[[Ordering@ids]]}]
$\endgroup$