Extract assertion functions
Add sort_by validation