System Design Leetcode Problems Javascript Array Sort Algorithm