[PD] Re : store and manipulate multiple lists

Andy Farnell padawan12 at obiwannabe.co.uk
Thu Mar 15 12:39:51 CET 2012


Yes of course. Once you can sort items of any type you can sort 
aggregate items, structs, sublists  or whatever on one of their
elements. Its a little messy in Pd. The best way might be to
use pointers and try to do the classic Kernighan and Richie
head swap thing but I have no idea how to exchange pointers in
Pd.

This attached thing should do the job and be adaptable to variable
record lengths. You might be able to hack it to work with symbols
as well as floats.

It totally fails if the keys are not ubique though :(

a.


On Wed, Mar 14, 2012 at 03:26:14PM -0700, Benoît Fortier wrote:
> Thanks Andy. But as far as I know, [list-sort] will sort the number in a list, and what I really need is to sort multiple lists according to their first element (which are numbers)... is there a trick with [list-sort] that allows to do that?
> 
> Benoît
> 
> 
> 
> ________________________________
>  De : Andy Farnell <padawan12 at obiwannabe.co.uk>
> À : Benoît Fortier <benoitfortier at yahoo.ca> 
> Cc : pd-list <pd-list at iem.at> 
> Envoyé le : mercredi 14 mars 2012 18h17
> Objet : Re: [PD] store and manipulate multiple lists
>  
> [list sort] 
> 
> maybe?
> 
> a.
> 
> On Wed, Mar 14, 2012 at 03:04:25PM -0700, Benoît Fortier wrote:
> > Hi everybody,
> > 
> > I need to store multiple lists of numbers in a text file in a specific order : the first number of each list must be ascending, from the first line of the text file to the last. The problem is this : my patch outputs the lists in an unordered way. I could rewrite the patch so that the lists gets outputed the correct way, but to be able to store all the lists somehow and then write a patch to order them afterward feels to me like a much more elegant solution. Any toughts on this?
> > 
> > Thank you all, this list has been very helpfull to me, and its also quite entertaining!
> > 
> > Benoît
> 
> > _______________________________________________
> > Pd-list at iem.at mailing list
> > UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-------------- next part --------------
#N canvas 1982 317 909 374 10;
#X msg 74 134 4 6545 3 3657 5 2333 1 3454 2 5464;
#X msg 363 151 1 3454 55555 2 5464 65656 4 6545 87678 3 3657 456 5
2333 7655 0 44444;
#X obj 296 297 print sorted;
#X obj 103 85 t b b;
#X msg 133 106 2;
#X obj 368 95 t b b;
#X msg 397 124 3;
#X obj 101 59 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 366 75 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 590 41 t b b;
#X obj 588 21 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X msg 575 100 1 234 3 345 0 12 3 333 4 410;
#X msg 619 70 2;
#X text 669 58 BUT BEWARE: must be unique keys;
#X text 67 37 Will sort pairs (record width is 2);
#X text 353 51 Here the record width is 3;
#X text 8 -8 [record-sort] use a pseudo hash to sort an incoming list
of n-tuples based on first item;
#X obj 296 269 record-sort;
#X connect 0 0 17 0;
#X connect 1 0 17 0;
#X connect 3 0 0 0;
#X connect 3 1 4 0;
#X connect 4 0 17 1;
#X connect 5 0 1 0;
#X connect 5 1 6 0;
#X connect 6 0 17 1;
#X connect 7 0 3 0;
#X connect 8 0 5 0;
#X connect 9 0 11 0;
#X connect 9 1 12 0;
#X connect 10 0 9 0;
#X connect 11 0 17 0;
#X connect 12 0 17 1;
#X connect 17 0 2 0;
-------------- next part --------------
#N canvas 0 0 450 300 10;
#X obj -259 109 list split 2;
#X obj -230 141 list;
#X obj -197 200 list prepend;
#X obj -113 200 t l;
#X obj -256 232 list split 1;
#X obj -275 176 t b a a;
#X obj -256 254 list prepend;
#X obj -170 254 t l;
#X obj -252 278 print keys;
#X obj -289 287 list;
#X obj -279 68 t b a b;
#X obj -292 339 list-sort;
#X obj -397 340 print sortedkeys;
#X obj -134 147 t b b;
#X obj -291 391 list-find;
#X obj -291 312 t a a;
#X obj -290 364 list-drip;
#X obj -279 492 list split;
#X obj -250 517 list split;
#X obj -226 456 *;
#X obj -287 449 list;
#X obj -289 422 t b f;
#X obj -64 81 t f f f;
#X obj -228 393 print index;
#X obj -284 38 inlet listdata;
#X obj -65 47 inlet recordwidth;
#X obj -251 543 outlet sorted fields;
#X text -341 15 TODO: fix to "handle" non unique keys in a sensible
way;
#X text -174 520 ajf;
#X connect 0 0 5 0;
#X connect 0 1 1 1;
#X connect 1 0 0 0;
#X connect 2 0 3 0;
#X connect 2 0 20 1;
#X connect 3 0 2 1;
#X connect 4 0 6 0;
#X connect 5 0 1 0;
#X connect 5 1 4 0;
#X connect 5 2 2 0;
#X connect 6 0 7 0;
#X connect 6 0 9 1;
#X connect 7 0 6 1;
#X connect 9 0 15 0;
#X connect 10 0 9 0;
#X connect 10 1 0 0;
#X connect 10 2 13 0;
#X connect 11 0 16 0;
#X connect 13 0 2 1;
#X connect 13 1 6 1;
#X connect 14 0 21 0;
#X connect 15 0 11 0;
#X connect 15 1 14 1;
#X connect 16 0 14 0;
#X connect 17 1 18 0;
#X connect 18 0 26 0;
#X connect 19 0 17 1;
#X connect 20 0 17 0;
#X connect 21 0 20 0;
#X connect 21 1 19 0;
#X connect 22 0 0 1;
#X connect 22 1 19 1;
#X connect 22 2 18 1;
#X connect 24 0 10 0;
#X connect 25 0 22 0;


More information about the Pd-list mailing list