Hi all,
It is amazing how we take things for granted. Most programming languages provide some sort of list sorting function/method. Surprisingly (or not) pd does not (or my search skills are null, or I am not bleeding edge enough). I needed a solution that works with a vanilla pd.
I was almost going to do the academia move and announce a pd exam, and have little pd-bees come up with a solution but I needed it *now* else I would not sleep or have terrible nightmares. So here it is. Thank heavens (but give your offerings to fbar's footils shrine) for list-abs.
Busy pd-bees, should you care to improve on my solution, please be my guest, I am sure there are better ways of accomplishing this trivial task. In any case, go forth and sort the world around (or within) you.
./MiS
Hallo, Michal Seta hat gesagt: // Michal Seta wrote:
It is amazing how we take things for granted. Most programming languages provide some sort of list sorting function/method. Surprisingly (or not) pd does not (or my search skills are null, or I am not bleeding edge enough). I needed a solution that works with a vanilla pd.
Actually there already is a [list-sort] in [list]-abs written by Jack Rybn. But I must say, your version is much shorter and probably easier to follow, so I would like to use your version if a) it has comparable speed and b) you don't mind?
Attached is a slight change which includes reverse sorting and makes your list-sort compatible with the one by Jack.
Frank Barknecht Do You RjDj.me? _ ______footils.org__
Hello Frank, Michal and list ! Seems to be shorter than mine. No problem for me to replace it. ++
Jack
Le 2 déc. 08 à 11:28, Frank Barknecht a écrit :
Hallo, Michal Seta hat gesagt: // Michal Seta wrote:
It is amazing how we take things for granted. Most programming languages provide some sort of list sorting function/method. Surprisingly (or not) pd does not (or my search skills are null, or I am not bleeding edge enough). I needed a solution that works with a vanilla pd.
Actually there already is a [list-sort] in [list]-abs written by Jack Rybn. But I must say, your version is much shorter and probably easier to follow, so I would like to use your version if a) it has comparable speed and b) you don't mind?
Attached is a slight change which includes reverse sorting and makes your list-sort compatible with the one by Jack.
Ciao
Frank Barknecht Do You RjDj.me? _
______footils.org__<list-sort-help.pd><list- sort.pd>_______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Hallo, Frank Barknecht hat gesagt: // Frank Barknecht wrote:
Attached is a slight change which includes reverse sorting and makes your list-sort compatible with the one by Jack.
Attached is another reworking: I got rid of one costly [list-drip] in the loop by directly calculating the positions of min and max instead of using list-find, and then I introduced a costly list-drip again (but it's only called once) to remove non-floats. Should be a little bit faster than the first version.
Frank Barknecht Do You RjDj.me? _ ______footils.org__
Hallo,
oh, and I also now committed two more abstractions that Matt Barber sent me offlist, of which one is a sorting abstraction as well. Matt's [list-shellsort] uses the Shell sorting algorithm: http://en.wikipedia.org/wiki/Shell_sort which generally is a bit faster than insertion sort, but I didn't benchmark the two Pd implementations (the speed in Pd of course also depends on how much element shuffling and list-dripping is needed)
Anyway, currently list-shellsort only does ascending sorting, so I just decided to include both Michal's list-sort, which probably is easier to understand, and Matt's list-shellsort in the current SVN's [list]-abs collection. Choose your poison. ;)
Frank
Michal Seta hat gesagt: // Michal Seta wrote:
Hi all,
It is amazing how we take things for granted. Most programming languages provide some sort of list sorting function/method. Surprisingly (or not) pd does not (or my search skills are null, or I am not bleeding edge enough). I needed a solution that works with a vanilla pd.
I was almost going to do the academia move and announce a pd exam, and have little pd-bees come up with a solution but I needed it *now* else I would not sleep or have terrible nightmares. So here it is. Thank heavens (but give your offerings to fbar's footils shrine) for list-abs.
Busy pd-bees, should you care to improve on my solution, please be my guest, I am sure there are better ways of accomplishing this trivial task. In any case, go forth and sort the world around (or within) you.
./MiS
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hi Frank and the bees,
I obviously haven't updated my list-abs collection in a while. So much happened while I was asleep... Thanks for the improvements. I pondered doing reverse sort but I didn't need it *now* :) And I also figured, there is always [list-rev] which could be used on the result of [list-sort] and so the latter can be kept simpler. But I suspect that your solution is less costly than sticking list-rev at the end of the chain.
list-shellsort sounds like fun but it is not pd-vanilla compatible.
Cheers
./MiS
On Tue, Dec 2, 2008 at 7:59 AM, Frank Barknecht fbar@footils.org wrote:
Hallo,
oh, and I also now committed two more abstractions that Matt Barber sent me offlist, of which one is a sorting abstraction as well. Matt's [list-shellsort] uses the Shell sorting algorithm: http://en.wikipedia.org/wiki/Shell_sort which generally is a bit faster than insertion sort, but I didn't benchmark the two Pd implementations (the speed in Pd of course also depends on how much element shuffling and list-dripping is needed)
Anyway, currently list-shellsort only does ascending sorting, so I just decided to include both Michal's list-sort, which probably is easier to understand, and Matt's list-shellsort in the current SVN's [list]-abs collection. Choose your poison. ;)
Ciao
Frank
Michal Seta hat gesagt: // Michal Seta wrote:
Hi all,
It is amazing how we take things for granted. Most programming languages provide some sort of list sorting function/method. Surprisingly (or not) pd does not (or my search skills are null, or I am not bleeding edge enough). I needed a solution that works with a vanilla pd.
I was almost going to do the academia move and announce a pd exam, and have little pd-bees come up with a solution but I needed it *now* else I would not sleep or have terrible nightmares. So here it is. Thank heavens (but give your offerings to fbar's footils shrine) for list-abs.
Busy pd-bees, should you care to improve on my solution, please be my guest, I am sure there are better ways of accomplishing this trivial task. In any case, go forth and sort the world around (or within) you.
./MiS
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-- Frank Barknecht Do You RjDj.me? _ ______footils.org__
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Tue, Dec 2, 2008 at 10:52 AM, Frank Barknecht fbar@footils.org wrote:
Oh, it is or at least should be! Maybe you're still missing some other list-abs. Which objects don't create for you?
I am sorry, I was not fully awake when I looked it up. It works fine in vanilla. Neat stuff.
Ciao
./MiS