find its position.
        const orderedKeyIndices = {};
        orderedKeys.forEach((key, index) => {
            orderedKeyIndices[key] = index;
        });

        // Define a custom sorting function that orders the keys based on the orderedKeys array.
        keys.sort((a, b) => {
            // Get the indices of keys a and b in orderedKeys.
            const indexA = orderedKeyIndices[a];
            const indexB = orderedKeyIndices[b];

            // If both keys exist in orderedKeys, sort them bas