refs.c: add a function to sort a ref list, rather then sorting on add