This visual trace shows sorting an array of objects by their 'val' property using a stable sort. The array starts as [{5,a}, {3,b}, {5,c}]. Step 1 compares first two elements and swaps because 5 > 3. Step 2 shows the array after swap: [{3,b}, {5,a}, {5,c}]. Step 3 compares equal values 5 and 5 and does not swap, preserving their original order, demonstrating stability. The final sorted array is [{3,b}, {5,a}, {5,c}]. Stability is important when equal elements must keep their relative order, such as sorting by multiple criteria. Unstable sorts may reorder equal elements, which can be faster but loses this order. Choose stable sorts like merge sort when order matters, and unstable sorts like quick sort when speed is priority and order doesn't matter.