Accion Labs needs a small in-memory utility to order records before displaying them in an internal engineering surface. Implement a stable bubble sort and demonstrate how inheritance and polymorphism can provide a consistent sorting interface for different record types.
Your implementation must sort a list of dictionaries in place by a named field. It must preserve the original relative order of records with equal keys, support ascending and descending order, and stop early when a complete pass makes no swaps.
Also define a base SortableRecord class with a sort_value() method, then create at least two subclasses that override this method. Explain how this override demonstrates polymorphism and how the subclasses inherit shared behavior from the base class.
Implement bubble_sort(records, key, reverse=False), where records is a list of dictionaries and key is the field used for comparison. Return the same list object after sorting. Values for the selected field are comparable integers or strings.
def bubble_sort(records, key, reverse=False):