[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sorting a multidimensional array



PureBytes Links

Trading Reference Links

First there's a problem of definition: what does it
_mean_ to sort a multidimensional array?

Suppose we have a 2 dimensional array
        Profits[manager][year]

The first dimension chooses one of eight different
fund managers, and the second dimension chooses
one of eleven different years.  There are a total of
8*11 = 88 different pieces of data.  Each of 8 managers
has 11 yearly profit results.

What does it mean to "sort" these data?

One answer might be, create a new 1-dimensional
array Sorted_Profits[n] which contains 88 elements.
Copy the 2D data from Profits[i][j] into the 1D array Sorted_Profits[n].
Then sort the 1D array Sorted_Profits[n].  This will give
you the 88 different profit values, sorted from smallest
to biggest, but you won't be able to tell which profit
came from which manager, in what year.  (You'll need
to do lookups to figure that out).




At 10:51 AM 6/12/2002 -0700, you wrote:


>Date: Wed, 12 Jun 2002 12:57:33 +0200
>From: "Gerart" <ga6p@xxxxxxxxxxxxx>
>To: <omega-list@xxxxxxxxxx>
>Subject: Easylanguage : How to sort a multidimensional array?
>Message-ID: <000b01c211ff$f9279a10$cce6c6d4@xxxxxxxx>
>Content-Type: text/plain;
>         charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>
>Hi,
>
>I'd like to sort a multidimensional array (up to 6 dimensions)
>and use a very fast algorithm (no "bubble sort" algorithm please).
>
>If anyone has the solution...
>
>Thanks !
>
>Gerart