In a test fixture for a NetApp BlueXP media dashboard, movie records must be displayed in a deterministic order. Given a list of movies, sort them by rating descending. Movies with the same rating must be sorted by title ascending, using case-sensitive lexicographic order. If two records have identical ratings and titles, preserve their original relative order.
Return a new sorted list without changing the input list.
Implement sort_movies(movies), where movies is a list of dictionaries. Each dictionary contains:
title: a non-empty stringrating: a number from 0 through 10, inclusiveReturn a list containing the same movie dictionaries in the required order. Do not create or remove movie records.
def sort_movies(movies):