Update sorting and add test file