huge rewrite, split to base and yandex-specific parts

> groupbysorted

looks good