[Purdue-pm] How to sort one dimension of a 2d array
Dave Jacoby
jacoby at purdue.edu
Fri Jan 29 08:55:45 PST 2010
So I fundamentally misunderstood the issue. OK.
This is the input, put into table form.
7 0 25 10
0 9 7 12
3 2 1 0
This is the desired output.
0 0 1 0
3 2 7 10
7 9 25 12
OK, now I get it. Kinda $x[$b][$a] instead of $x[$a][$b]. So, thinking
of it as a table or matrix instead of an array of arrays. Not
unreasonable, but computer science discourages thinking like that.
Rick Westerman wrote:
>
> 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
>
> _______________________________________________
> Purdue-pm mailing list
> Purdue-pm at pm.org
> http://mail.pm.org/mailman/listinfo/purdue-pm
--
Dave Jacoby Address: WSLR S049
Genomics Core Programmer Mail: jacoby at purdue.edu
Purdue University Jabber: jacoby at jabber.org
Phone: 765.49.67368
More information about the Purdue-pm
mailing list