now using a stable sort algorithm for 'sortChildren' (closes #304)

It's a merge sort algorithm that doesn't do any allocations while it runs.