Adds functions sort_and_count and merge_and_count_split