• ### How can I get the original order of a accending/decending resorted list?

Hey!

I have a list of let's say 8 number:
42 31 96 29 53 32 39 16

Then I sort them from low>high using list-sort abs from list-abs:
16 29 31 32 39 42 53 96

This works fine, but the next step I am not even sure where to begin with.

The next step I would like to do is to get the order of the reordered list, which in this case would be:
7 3 1 5 6 0 4 2

The 7th element of the original list is now first, the 3rd element of the first list is now second and so on.

How would I go about getting the order of the reordered list?

I would like to apply that same order from that list to some other lists.

I checked list-sort abs and printet some of the data from the different processes, but I didn't find the actual order. I am really not familiar with data structures.

Any suggestions?

(the length of is just an example, the lists are going to be longer, sometimes 16 elements, sometimes 64 elements.....=

Thanks!

Here is a starting point:
list-sort-help-com.pd

• Posts 14 | Views 3033
• @jaffasplaffa This will output the sorted list at the left outlet and the positions at the right outlet:

sortlist.pd

• @ingox

Wow, that was fast

A lot smarter than what I was playing around with.

Thank you very much

• @jaffasplaffa This sorts descending:

sortlist-desc.pd

• Thanks I will check the decending order out too. I noticed issues when doing the decending order here.

I did make one here, where I use list-rev, for the decending order. That works.

• @jaffasplaffa Which issues?

• It reversed the order, as far as I could see. If I did a list-rev for the order only, it seemed to work.

But yeah I tried the last one you posted and that one works perfectly

• @jaffasplaffa I believe all versions are working correctly.

Anyhow, looking at the help file of [list-sort], a difference is that [sortlist] replaces non-floats with zeros without warning. On the other hand, [sortlist] is two to three times faster.

• So here is a version that is a little bit slower on only-float lists then the above [sortlist], but still faster than [list-sort].

This one is also able to sort lists that contain symbols. It relies on the sorting method of [text]. Therefor "numbers come before symbols, which are sorted alphabetically (details such as case sensitivity (does 'b' come before 'A'?) may depend on operating system). Shorter lines come before longer ones that match the entire shorter lines." (from [text define] help)

sortlist_text.pd

• @ingox I am going to rename your account from @ingox to @[store]Master
Joking of course....
David.

• @whale-av Well, the fun i had with the above solutions was sorting the lists without looking at the elements at all. The first approach uses [array min]/[array max] to sort the list, the second approach just uses the sorting method of [text]. Both methods are therefor somewhat efficient.

• Hey guys!

Sorry for the late reply. Had a really long and rough week. My mom just got cancer, so have not had time for PD for a while.

I will check your posts and learn from the storemasters. I think you both are in that category

• @jaffasplaffa All the best to you and your mom!

Posts 14 | Views 3033
Internal error.

Oops! Looks like something went wrong!