-1

I made an array of data. so it looks like:

Array
(
    [0] => Array
        (
            [0] => something1
            [1] => something2
            [2] => something3
            [3] => something4
            [4] => something5
            [5] => something6
        )

    [1] => Array
        (
            [0] => 3666
            [1] => 48
            [2] => 6
            [3] => 1
            [4] => 1
            [5] => 215
        )

)

I want to sort the array:

Array
(
    [0] => Array
        (
            [3] => something4
            [4] => something5
            [2] => something3
            [1] => something2
            [5] => something6
            [0] => something1
        )

    [1] => Array
        (
            [3] => 1
            [4] => 1
            [2] => 6
            [1] => 48
            [5] => 215
            [0] => 3666
        )

)

How can i do that ? Please, any helpful advice. I tried to use arsort and the sort, but I do not really understand what's going on. Arrays for me fresh topic I am weak in English, so please write in a simple way - thank you!

coderabbit
  • 77
  • 9
  • I'm guessing `php` since he tried `arsort`. Possible duplicate: http://stackoverflow.com/q/348410/2033671 –  Jan 08 '14 at 23:48

1 Answers1

0

From the syntax of your question, I'm assuming this is PHP.

Your desired output has one sub-array sorted descending, and another one sorted ascending. It also appears that you also want to maintain the correlation between the array indexes and their values.

You need to do this in two steps:

arsort(Array[0]) will sort the first array in descending order.

asort(Array[1]) will sort the second array in ascending order.

Anachronist
  • 1,032
  • 12
  • 16