[Purdue-pm] How to sort one dimension of a 2d array

Rick Westerman westerman at purdue.edu
Fri Jan 29 08:27:06 PST 2010


On Jan 29, 2010, at 11:08 AM, Dave Jacoby wrote:

> So, you're wanting to sort the inner arrays.

Dave:

     Although your solution is good for sorting inner arrays it does  
not replicate what Phillip stated in his example.  Phillip's example  
still seems bizarre to me but there is probably a good reason behind it.

Dave's output
>
> $VAR1 = [
>   [
>     0,
>     7,
>     10,
>     25
>   ],
>   [
>     0,
>     7,
>     9,
>     12
>   ],
>   [
>     0,
>     1,
>     2,
>     3
>   ]
> ];
>
>


Phillip's desired output:


>> But what I want is:
>> $VAR1 = [
>>          [
>>            0,
>>            0,
>>            1,
>>            0
>>          ],
>>          [
>>            3,
>>            2,
>>            7,
>>            10
>>          ],
>>          [
>>            7,
>>            9,
>>            25,
>>            12
>>          ]
>>        ];


-- Rick



More information about the Purdue-pm mailing list