use a stable sort in COLLECT