Fixed sorting of stream

Fixes #40