Custom String Sort

Sorting Strings Custom Sort Algorithm Coding Challenge

Problem: Custom String Sort

On April 14, as we welcome the vibrancy of spring, many communities celebrate the renewal of nature. Imagine you have a list of festive event names or seasonal greetings. Your task is to sort this list according to the following criteria:

  1. Primary Sort: By the length of the string in ascending order.
  2. Secondary Sort: For strings with the same length, sort them in lexicographic (alphabetical) order.

Example

For an input array:

["SpringFest", "Bloom", "Easter", "Fest", "Vivid"]

The sorted output should be:

["Fest", "Bloom", "Easter", "Vivid", "SpringFest"]

Instructions

Implement a function customSort that takes as input an array (or list) of strings and returns a new array sorted based on the criteria above. Ensure that your implementation is efficient and follows the principles of sorting algorithms.

Note: While built-in sorting functions are allowed, try to highlight any custom sorting logic explicitly in your code.