Note: The sorting feature is only enabled for playlists containing 100 videos or less. This is because for larger playlists (>100 videos), YouTube only loads the next 100 videos after you scroll to ...
ytmusicapi is a Python 3 library to send requests to the YouTube Music API. It emulates YouTube Music web client requests using the user's cookie data for authentication.