MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Following position change in different vectors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117493] Re: Following position change in different vectors
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Mon, 21 Mar 2011 06:12:18 -0500 (EST)

What about

{v1sorted, v2sorted} = Transpose[Sort[Transpose[{v1, v2}]]]


Heike

On 20 Mar 2011, at 09:53, Lengyel Tamas wrote:

> Dear Mathworld Users,
> 
> Sorry for asking your help again, I hope I'm not spamming too much.
> My problem is the following:
> 
> 1) I have 2 vectors with equal length. The positions of the first vector
> correspond to the second vector. So the first element of v2 is calculated
> from the first element of v1, etc.
> 
> 2) I wish to sort the first vector in ascending magnitude using Sort[v1].
> Naturally the positions of v1's elements change.
> 
> What I want is the same change of position in v2's positions.
> 
> (So e.g. if v1's sixth element moves after Sort to  the first position,
> I'd like v2's same position element to follow suit)
> 
> Thank you for your help in advance.
> 
> Tamas
> 



  • Prev by Date: Jacobian
  • Next by Date: Why Mathematica does not issue a warning when the calculations are losing so much precision that the results are not anymore useful?
  • Previous by thread: Following position change in different vectors
  • Next by thread: Re: Following position change in different vectors