Customize sorting of list view and tags update

Hello everyone,
I have a new doctype ip (in a custom app), ip sorting is different from strings, how can I do custom sorting?

def ip_sort(list_ip):
    items = sorted(list_ip.items(), key=lambda item: socket.inet_aton(item[0]))
    return items

I miss how to build the query and how to invoke the function in list view

Meanwhile, I also ask what event triggers the modification of a search input (in list view). Now refresh the list after a change, but I would like to refresh the whole page to immediately update the number of tags without having to do f5 manually.

thanks for your time