Steps for you:
Sort Object Keys Alphabetically (Case-Insensitive): Use Object.keys() to get all keys of an object and sort them with .sort(), using localeCompare for case-insensitive comparison. Apply this recursively for nested objects.
Preserve Original Structure; Make sure arrays remain arrays and objects remain objects. Use a recursive approach to traverse and process each element based on its type (Array.isArray() and typeof).
Remove Duplicate Objects: Serialize objects using JSON.stringify() and use a Set to store and compare them. This will help you remove duplicates while keeping the first occurrence intact.
Remove Empty Properties: Define a helper function to detect "empty" values like null, undefined, empty arrays, or objects. Use this function recursively to clean up unwanted properties from your data.
You can look-up everything to understand it here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects