[PD] sorting a 2 dimension list

Frank Barknecht fbar at footils.org
Thu Feb 17 22:56:10 CET 2005


Hallo,
Thomas Ouellet Fredericks hat gesagt: // Thomas Ouellet Fredericks wrote:

> Please help, I can not figure this out:
> 
> How can I sort a multidimensional list by it's first element?
> I know of a way using [coll] (cyclone) but from my experience, [coll] is 
> unstable.
> 
> Example : how do I sort the following list [[2,3],[7,4],[5,3],[6,7]] ?
> The result would be : [[2,3],[5,3],[6,7],[7,4]]

I'd suggest the Georg Holzmann's wonderful PDContainer externals for
this, they are in CVS and provide various very useful data types. In
your case, you can directly use "h_list" like in attached patch.

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
             _ __latest track: fqdn _ http://footils.org/cms/show/38
-------------- next part --------------
#N canvas 503 183 450 300 10;
#N canvas 0 0 450 300 hlist-here 0;
#X obj 91 185 h_list;
#X obj 91 144 inlet;
#X text 179 196 Do you have PDContainer installed?;
#X connect 1 0 0 0;
#X restore 255 255 pd hlist-here;
#X obj 48 126 t b b;
#X obj 48 98 until;
#X obj 48 189 pack 0 0;
#X obj 48 161 random 100;
#X obj 123 160 random 200;
#X msg 180 61 print;
#X msg 255 60 sort;
#X msg 324 59 print;
#X text 78 35 ==> fill \, print \, sort \, print again:;
#X msg 48 216 insert \$1 \$2;
#X msg 109 63 10;
#X msg 294 226 clear;
#X connect 1 0 4 0;
#X connect 1 1 5 0;
#X connect 2 0 1 0;
#X connect 3 0 10 0;
#X connect 4 0 3 0;
#X connect 5 0 3 1;
#X connect 6 0 0 0;
#X connect 7 0 0 0;
#X connect 8 0 0 0;
#X connect 10 0 0 0;
#X connect 11 0 2 0;
#X connect 12 0 0 0;


More information about the Pd-list mailing list