Sorting collections of agents stably (fixes #95)