I'm trying to learn scala with Akka Actors.

I’m trying to an develop actor code to implement this[below info] for sorting positive integers, Using 0 to indicate the end of the values to be sorted.

It is possible to sort a number of values using a pipeline of filter actors, each responsible for one value: the first actor picks the smallest value, the second the second smallest and so on. Particularly, the first actor receives all the values, one by one. If there are more than one values received by an actor, it creates another actor; it keeps the smallest value received so far for itself, and sends all other values forward to the actor it created. Each filter actor does the same thing.

Assume that each filter actor has local storage for only two of the values to be sorted: the next incoming value and the minimum value seen thus far.

A sentinel is used to indicate the end of the values to be sorted. The sentinel is then sent down the pipeline to inform all actors of the end of the input. On receiving the sentinel, each filter actor replies to the sender of the sentinel with its smallest value. All actors simply forward back the values they receive from actors down the pipeline from them, so that the first actor receives all the values in a sorted order, and sends them forward to the original requester, one value at a time.

I’m not sure what the question here is, but regardless, you may find the Akka Forum more helpful…

1 Like