Leetcode Array Sort Python Function Vs Method