Random Former Index in the SORT node

When using the sort (spreads), and having some equal values in your spread, the ‘Former Index’ pin seems to ‘random’ the sequence off the slices that are double.

In the forum I found some people got the same problem, but cannot find the solution! someone can tell me how did you solved this?

SortFormerIndex.v4p (6.2 kB)

I think it’s a result of the used sorting algorithm.

SortSort.v4p (6.5 kB)

yep!
Thanks :D

https://discourse.vvvv.org/t/3347

Very old bug, hope it gets fixed some day…

as björn pointed out, this is a feature of the sorting algorithm. i guess our algorithm is not ‘stable’. where stable means, it keeps the order where ever possible.

here is a big comparison:
http://en.wikipedia.org/wiki/Sorting_algorithm

if one finds the time, we could look for another algorithm.

so, which algorithm is in the nodes now?

the vvvv node uses a quicksort implementation.

seems as if the Sort (Spreads Advanced) from the addonpack uses a stable sorting algorithm.

yes so it seems but it reverses the slide order.

Array.sort() does exactly the same…

SortSharp.rar (18.6 kB)

the Sort (Spreads) node uses a stable mergesort algorithm now, check latest alpha28.3.