);
                        }
                    }
                });
                
                // Apply the new order efficiently
                applyOrder(parentElement, finalNodes);
                
                return null;
            }

            function generateHash(obj) {
                return JSON.stringify(obj, Object.keys(obj).sort());
            }

            function applyOrder(parentElement, finalNodes) {
                const currentNodes = Array.from(parentElement.children)