I haven't found the source of the issue, but sorting on library doesn't work for patron searches in Koha 21.11, but it does work in Koha 22.05.