This patch adds stabilizeTable to replace duplicate code involving
O(N) heap allocations and hash lookups. The new helper function
returns pointers to key-value pairs sorted by key.
Since the keys in MapVector are already guaranteed to be unique,
using std::set for sorting allocates unnecessary tree nodes on the
heap.
Assisted-by: Antigravity