Hello, I'm trying to realize something like that: I have different lists that I have to sort in ascending order according to their first element, but I cannot find a solution.
In other words I'd like to have the lists (1 a b c) (5 d e f) (3 g h i)
ordered in this way: (1 a b c) (3 g h i) (5 d e f)
thanks a lot,
Libero
Hi,
On 27/07/10 12:56, Libero Mureddu wrote:
Hello, I'm trying to realize something like that: I have different lists that I have to sort in ascending order according to their first element, but I cannot find a solution.
It's a tricky one in vanilla Pd.
In other words I'd like to have the lists (1 a b c) (5 d e f) (3 g h i)
ordered in this way: (1 a b c) (3 g h i) (5 d e f)
If you have pd-lua, try the attached, it's not totally perfect (ie, no checking for lengths of lists so if you try to sort by an index that is too big you get errors) but it works for your example.
thanks a lot,
Libero
Hi,
On Tue, Jul 27, 2010 at 02:00:39PM +0100, Claude Heiland-Allen wrote:
On 27/07/10 12:56, Libero Mureddu wrote:
Hello, I'm trying to realize something like that: I have different lists that I have to sort in ascending order according to their first element, but I cannot find a solution.
It's a tricky one in vanilla Pd.
If the lists to sort always have the same structure, one could use data structures for this. Attached is an example. Of course, appending the data takes some time as well, and [append] doesn't like symbols, but depending on what you want to do, this can be a fast, vanilla way to sort lists.
In the attachement, the lists are always "<number> a b c", but of course the "a b c" part can change and will survive sorting.
Frank