Visually sorting algorithm

Hey!

I found these beautiful sorting algorithms: https://www.toptal.com/developers/sorting-algorithms

… and try to patch one of them.

So since I am new to v4 (first post here :), its hard to get the logic done. basically I need a condition within a loop and a counter of course to swap the spread in the right order.

in textual programming you would do it like this:

do
swapped = false
for i = 1 to indexOfLastUnsortedElement
  if leftElement > rightElement
    swap(leftElement, rightElement)
    swapped = true; swapCounter++
while swapped

I attached my patch, but its still a long way to go :D

sorting_algo.v4p (18.9 kB)

insert some devvvv comment about VL beeing your saviour someday in the future.

hi _e, as guest already noticed, this is totally a VL topic.

in vvvv FOR loops are implicitly integrated into the nodes and you cannot (easily) write a function that is calculated in a loop per frame.

in VL however FOR, IF and other language constructs are first class members and you can use and combine them as in your code example.

Thanks both of you for the replies!
VL seems to be more convenient for this task. I will install VL and give it a try.

But for the record: it should be anyhow possible in v4 right?

it is certainly possible to visualize a sorting algorithm for educational purposes in vvvv, but because of the high level nature of vvvv, it is rather a tool that uses algorithms than one that is used to implement them.