Refactor and implement sorting and filtering in the datasources