I want to make a patch that sets the elements (unique floats actually) of a list in accelarating order.
I have written this loop in fake-pd-code, where "i" and "k" are list's indeces.
What actually does is to take all elements, one by one ( from index=0 until the last element (index=
-1)) and compare it with the rest af the lists' elements. As long as our ellement is bigger than the one is been compared with, we compare it with the next element of the list.
As soon as it finds itself or bigger float in its quest, then we put it before that float,
delete it from the previus position that is allways its index pos+1
exit "quest"
and
do the same seartch for the next ellement of the list.
So here it is:
.----------->For(i=0, until i==list lenght)
| -------> do {
| | for (k=0, until do-is-exit)
| | do {
| | if (list-idx(i) > list-idx(k)) {
| | k++;
| | }
| | else {
| | list-insert(in pos -> k)=list-idx(i);
| | list-delete(pos -> i+1);
| <------------------------- exit do;
|
.<--------------------------------------- i++;
I use [list-idx], [list-insert], [list-delete] & Has someone have any idea how to do it, because so far i only get stack overflows from everywhere,
or any other idea of how we order a list of floats.
EG/, Actually i want to order a list of pairs where we compare the second element of every pair and order it:
ex. list [2 2.5 3 7.8 8 1.1 4 4.2 1 2] --> [8 1.1 1 2 4 2.2 2 2.5 3 7.8] (ordered by 1.1 2 2.2 2.5 7.8 )