Feature/sort collections

Fixes #495