Well, this code in particular is actually covered by tests.
But will write some more to check sorting.