Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
array sort

Subject: array sort

From: muzaffar

Date: 23 Apr, 2008 13:27:01

Message: 1 of 6

Hi,
i want to sort an array while keeping the array index also
sorted with the value of the array.

i want to do the following
(i)
A=76
B=45
C=43
D=33
E=80
i want to sort these as if
  D C B A E
  33 43 45 76 80
 
(ii) for an array e.g k
index 1 2 3 4 5 6 7 8 9
  k = [ 2 5 6 4 1 2 3 6 8]

i want to do

index 5 1 6 7 4 2 3 8 9
  k = [ 1 2 2 3 4 5 6 6 8 ]


       
how i can keep track of array index after sort
kind regards.

Subject: array sort

From: us

Date: 23 Apr, 2008 13:45:04

Message: 2 of 6

"muzaffar ":
<SNIP must read the help - again...

> how i can keep track of array index after sort...

a hint:

% peruse(!)
     help sort;

us

Subject: array sort

From: us

Date: 23 Apr, 2008 13:45:04

Message: 3 of 6

"muzaffar ":
<SNIP must read the help - again...

> how i can keep track of array index after sort...

a hint:

% peruse(!)
     help sort;

us

Subject: array sort

From: us

Date: 23 Apr, 2008 13:45:04

Message: 4 of 6

"muzaffar ":
<SNIP must read the help - again...

> how i can keep track of array index after sort...

a hint:

% peruse(!)
     help sort;

us

Subject: array sort

From: us

Date: 23 Apr, 2008 13:45:04

Message: 5 of 6

"muzaffar ":
<SNIP must read the help - again...

> how i can keep track of array index after sort...

a hint:

% peruse(!)
     help sort;

us

Subject: array sort

From: muzaffar

Date: 24 Apr, 2008 07:32:01

Message: 6 of 6

Hi,
i want to sort an array
i want to do the following
A E B C D
76 80 45 43 33
 

i want to sort these as if
   D C B A E
  33 43 45 76 80


"muzaffar " <muzaffarbashir@yahoo.com> wrote in message
<fundf5$nsj$1@fred.mathworks.com>...
> Hi,
> i want to sort an array while keeping the array index
also
> sorted with the value of the array.
>
> i want to do the following
> (i)
> A=76
> B=45
> C=43
> D=33
> E=80
> i want to sort these as if
> D C B A E
> 33 43 45 76 80
>
> (ii) for an array e.g k
> index 1 2 3 4 5 6 7 8 9
> k = [ 2 5 6 4 1 2 3 6 8]
>
> i want to do
>
> index 5 1 6 7 4 2 3 8 9
> k = [ 1 2 2 3 4 5 6 6 8 ]
>
>
>
> how i can keep track of array index after sort
> kind regards.
>

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us