Applying sorting and search