use sorted collections to make tests deterministic #1119 #1120