Sorting and searching codes