Custom Object Sort

Sorting Custom Comparator Algorithm Coding Problem Data Structures

Problem: Custom Object Sort

You are given an array of objects where each object has two properties:

  • name: a string
  • count: an integer

Write a function that sorts the array using the following criteria:

  1. Primary sort: Descending order by the count property.
  2. Secondary sort: If two objects have the same count, sort them in ascending alphabetical order by the name property.

Your task is to implement a sorting algorithm (e.g., merge sort, quick sort, etc.) without using built-in sorting functions. This problem will help you practice implementing sorting algorithms along with custom comparator logic.

Hint: Think about how you can modify a standard sort to account for two sorting criteria.

Good luck and happy coding on this day of celebrating order and structure!