{"id":331,"date":"2025-07-26T13:56:09","date_gmt":"2025-07-26T13:56:09","guid":{"rendered":"https:\/\/vijaypandit.in\/?page_id=331"},"modified":"2025-07-26T13:56:09","modified_gmt":"2025-07-26T13:56:09","slug":"sort-lines-alphabetically","status":"publish","type":"page","link":"https:\/\/vijaypandit.in\/?page_id=331","title":{"rendered":"Sort Lines Alphabetically"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Sort Lines Alphabetically Tool<\/title>\n    <style>\n        * {\n            margin: 0;\n            padding: 0;\n            box-sizing: border-box;\n        }\n\n        .gp-sort-lines-tool {\n            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n            background-color: #f5f5f5;\n            min-height: 100vh;\n            padding: 20px;\n        }\n\n        .gp-sort-lines-container {\n            max-width: 1200px;\n            margin: 0 auto;\n        }\n\n        .gp-sort-lines-header {\n            background: white;\n            padding: 25px;\n            border-radius: 12px;\n            box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n            margin-bottom: 20px;\n            display: flex;\n            align-items: center;\n            gap: 20px;\n        }\n\n        .gp-sort-lines-icon {\n            width: 80px;\n            height: 80px;\n            background: linear-gradient(135deg, #4285f4, #1a73e8);\n            border-radius: 16px;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            font-size: 32px;\n            font-weight: 900;\n            color: white;\n            flex-shrink: 0;\n        }\n\n        .gp-sort-lines-title-section h1 {\n            font-size: 32px;\n            color: #000;\n            font-weight: 900;\n            margin-bottom: 8px;\n        }\n\n        .gp-sort-lines-title-section p {\n            font-size: 18px;\n            color: #000;\n            font-weight: 700;\n        }\n\n        .gp-sort-lines-main {\n            display: grid;\n            grid-template-columns: 1fr 1fr;\n            gap: 20px;\n            margin-bottom: 20px;\n        }\n\n        .gp-sort-lines-section {\n            background: white;\n            border-radius: 12px;\n            padding: 25px;\n            box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n            height: fit-content;\n        }\n\n        .gp-sort-lines-section h2 {\n            font-size: 20px;\n            color: #000;\n            font-weight: 900;\n            margin-bottom: 15px;\n            display: flex;\n            align-items: center;\n            gap: 10px;\n        }\n\n        .gp-sort-lines-textarea {\n            width: 100%;\n            height: 300px;\n            border: 2px solid #e0e0e0;\n            border-radius: 8px;\n            padding: 15px;\n            font-family: 'Segoe UI', monospace;\n            font-size: 14px;\n            font-weight: 700;\n            color: #000;\n            resize: vertical;\n            transition: border-color 0.3s ease;\n        }\n\n        .gp-sort-lines-textarea:focus {\n            outline: none;\n            border-color: #4285f4;\n        }\n\n        .gp-sort-lines-controls {\n            margin-top: 15px;\n            display: flex;\n            flex-wrap: wrap;\n            gap: 15px;\n        }\n\n        .gp-sort-lines-option {\n            display: flex;\n            align-items: center;\n            gap: 8px;\n        }\n\n        .gp-sort-lines-option label {\n            font-weight: 700;\n            color: #000;\n            cursor: pointer;\n            font-size: 14px;\n        }\n\n        .gp-sort-lines-option input[type=\"checkbox\"] {\n            width: 18px;\n            height: 18px;\n            cursor: pointer;\n        }\n\n        .gp-sort-lines-select {\n            padding: 8px 12px;\n            border: 2px solid #e0e0e0;\n            border-radius: 6px;\n            font-family: 'Segoe UI', sans-serif;\n            font-weight: 700;\n            color: #000;\n            background: white;\n            cursor: pointer;\n        }\n\n        .gp-sort-lines-button {\n            background: #000;\n            color: white;\n            border: none;\n            padding: 12px 20px;\n            border-radius: 8px;\n            font-family: 'Segoe UI', sans-serif;\n            font-weight: 700;\n            font-size: 14px;\n            cursor: pointer;\n            transition: all 0.3s ease;\n            display: flex;\n            align-items: center;\n            gap: 8px;\n        }\n\n        .gp-sort-lines-button:hover {\n            background: #333;\n            transform: translateY(-2px);\n            box-shadow: 0 4px 12px rgba(0,0,0,0.2);\n        }\n\n        .gp-sort-lines-button:active {\n            transform: translateY(0);\n        }\n\n        .gp-sort-lines-button.secondary {\n            background: #666;\n        }\n\n        .gp-sort-lines-button.secondary:hover {\n            background: #555;\n        }\n\n        .gp-sort-lines-actions {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 12px;\n            margin-top: 15px;\n        }\n\n        .gp-sort-lines-stats {\n            background: white;\n            border-radius: 12px;\n            padding: 25px;\n            box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n            margin-bottom: 20px;\n        }\n\n        .gp-sort-lines-stats h2 {\n            font-size: 20px;\n            color: #000;\n            font-weight: 900;\n            margin-bottom: 15px;\n        }\n\n        .gp-sort-lines-stats-grid {\n            display: grid;\n            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n            gap: 20px;\n        }\n\n        .gp-sort-lines-stat {\n            text-align: center;\n        }\n\n        .gp-sort-lines-stat-number {\n            font-size: 32px;\n            font-weight: 900;\n            color: #D97757;\n            display: block;\n            margin-bottom: 5px;\n            transition: all 0.3s ease;\n        }\n\n        .gp-sort-lines-stat-label {\n            font-size: 14px;\n            font-weight: 900;\n            color: #000;\n        }\n\n        .gp-sort-lines-description {\n            background: #CBCADC;\n            border-left: 4px solid #D97757;\n            padding: 20px;\n            border-radius: 8px;\n            margin-bottom: 20px;\n        }\n\n        .gp-sort-lines-description h3 {\n            font-size: 18px;\n            color: #000;\n            font-weight: 900;\n            margin-bottom: 10px;\n        }\n\n        .gp-sort-lines-description p {\n            font-size: 14px;\n            color: #000;\n            font-weight: 700;\n            line-height: 1.5;\n        }\n\n        .gp-sort-lines-history {\n            background: white;\n            border-radius: 12px;\n            padding: 25px;\n            box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n            margin-bottom: 20px;\n        }\n\n        .gp-sort-lines-history h2 {\n            font-size: 20px;\n            color: #000;\n            font-weight: 900;\n            margin-bottom: 15px;\n        }\n\n        .gp-sort-lines-history-item {\n            background: #f8f9fa;\n            border: 1px solid #e0e0e0;\n            border-radius: 6px;\n            padding: 12px;\n            margin-bottom: 10px;\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n        }\n\n        .gp-sort-lines-history-text {\n            font-size: 14px;\n            color: #000;\n            font-weight: 700;\n            flex: 1;\n        }\n\n        .gp-sort-lines-history-restore {\n            background: #4285f4;\n            color: white;\n            border: none;\n            padding: 6px 12px;\n            border-radius: 4px;\n            font-weight: 700;\n            font-size: 12px;\n            cursor: pointer;\n        }\n\n        .gp-sort-lines-toast {\n            position: fixed;\n            top: 20px;\n            right: 20px;\n            background: #000;\n            color: white;\n            padding: 12px 20px;\n            border-radius: 8px;\n            font-weight: 700;\n            z-index: 1000;\n            transform: translateX(400px);\n            transition: transform 0.3s ease;\n        }\n\n        .gp-sort-lines-toast.show {\n            transform: translateX(0);\n        }\n\n        .gp-sort-lines-pulse {\n            animation: pulse 0.5s ease-in-out;\n        }\n\n        @keyframes pulse {\n            0% { transform: scale(1); }\n            50% { transform: scale(1.1); }\n            100% { transform: scale(1); }\n        }\n\n        \/* Mobile Responsive *\/\n        @media (max-width: 768px) {\n            .gp-sort-lines-tool {\n                padding: 15px;\n            }\n\n            .gp-sort-lines-header {\n                flex-direction: column;\n                text-align: center;\n                padding: 20px;\n            }\n\n            .gp-sort-lines-title-section h1 {\n                font-size: 24px;\n            }\n\n            .gp-sort-lines-title-section p {\n                font-size: 16px;\n            }\n\n            .gp-sort-lines-main {\n                grid-template-columns: 1fr;\n                gap: 15px;\n            }\n\n            .gp-sort-lines-section {\n                padding: 20px;\n            }\n\n            .gp-sort-lines-textarea {\n                height: 250px;\n            }\n\n            .gp-sort-lines-stats-grid {\n                grid-template-columns: repeat(2, 1fr);\n                gap: 15px;\n            }\n\n            .gp-sort-lines-actions {\n                flex-direction: column;\n            }\n\n            .gp-sort-lines-button {\n                width: 100%;\n                justify-content: center;\n            }\n\n            .gp-sort-lines-controls {\n                flex-direction: column;\n                gap: 10px;\n            }\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"gp-sort-lines-tool\">\n        <div class=\"gp-sort-lines-container\">\n            <!-- Header -->\n            <div class=\"gp-sort-lines-header\">\n                <div class=\"gp-sort-lines-icon\">A\u2192Z<\/div>\n                <div class=\"gp-sort-lines-title-section\">\n                    <h1>Sort Lines Alphabetically<\/h1>\n                    <p>Organize your text lines in perfect alphabetical order with advanced sorting options<\/p>\n                <\/div>\n            <\/div>\n\n            <!-- Description with rotating tips -->\n            <div class=\"gp-sort-lines-description\" id=\"descriptionBox\">\n                <h3>Pro Tip<\/h3>\n                <p id=\"rotatingTip\">Perfect for organizing lists, bibliographies, contact information, and any text that needs alphabetical ordering.<\/p>\n            <\/div>\n\n            <!-- Main Content -->\n            <div class=\"gp-sort-lines-main\">\n                <!-- Input Section -->\n                <div class=\"gp-sort-lines-section\">\n                    <h2>\ud83d\udcdd Input Text<\/h2>\n                    <textarea \n                        class=\"gp-sort-lines-textarea\" \n                        id=\"inputText\" \n                        placeholder=\"Enter your text lines here...\nEach line will be sorted alphabetically.\n\nExample:\nZebra\nApple\nBanana\nCherry\"\n                    ><\/textarea>\n                    \n                    <div class=\"gp-sort-lines-controls\">\n                        <div class=\"gp-sort-lines-option\">\n                            <input type=\"checkbox\" id=\"caseInsensitive\" checked>\n                            <label for=\"caseInsensitive\">Case Insensitive<\/label>\n                        <\/div>\n                        <div class=\"gp-sort-lines-option\">\n                            <input type=\"checkbox\" id=\"reverseOrder\">\n                            <label for=\"reverseOrder\">Reverse Order (Z\u2192A)<\/label>\n                        <\/div>\n                        <div class=\"gp-sort-lines-option\">\n                            <input type=\"checkbox\" id=\"removeEmpty\" checked>\n                            <label for=\"removeEmpty\">Remove Empty Lines<\/label>\n                        <\/div>\n                        <div class=\"gp-sort-lines-option\">\n                            <input type=\"checkbox\" id=\"removeDuplicates\">\n                            <label for=\"removeDuplicates\">Remove Duplicates<\/label>\n                        <\/div>\n                        <div class=\"gp-sort-lines-option\">\n                            <label for=\"sortBy\">Sort By:<\/label>\n                            <select class=\"gp-sort-lines-select\" id=\"sortBy\">\n                                <option value=\"alphabetical\">Alphabetical<\/option>\n                                <option value=\"length\">Line Length<\/option>\n                                <option value=\"numerical\">Numerical<\/option>\n                                <option value=\"random\">Random<\/option>\n                            <\/select>\n                        <\/div>\n                    <\/div>\n\n                    <div class=\"gp-sort-lines-actions\">\n                        <button class=\"gp-sort-lines-button\" onclick=\"sortLines()\">\n                            \ud83d\udd04 Sort Lines\n                        <\/button>\n                        <button class=\"gp-sort-lines-button secondary\" onclick=\"clearInput()\">\n                            \ud83d\uddd1\ufe0f Clear\n                        <\/button>\n                        <button class=\"gp-sort-lines-button secondary\" onclick=\"undoAction()\">\n                            \u21b6 Undo\n                        <\/button>\n                        <button class=\"gp-sort-lines-button secondary\" onclick=\"redoAction()\">\n                            \u21b7 Redo\n                        <\/button>\n                    <\/div>\n                <\/div>\n\n                <!-- Output Section -->\n                <div class=\"gp-sort-lines-section\">\n                    <h2>\u2705 Sorted Output<\/h2>\n                    <textarea \n                        class=\"gp-sort-lines-textarea\" \n                        id=\"outputText\" \n                        readonly\n                        placeholder=\"Your sorted lines will appear here...\"\n                    ><\/textarea>\n\n                    <div class=\"gp-sort-lines-actions\">\n                        <button class=\"gp-sort-lines-button\" onclick=\"copyToClipboard()\">\n                            \ud83d\udccb Copy to Clipboard\n                        <\/button>\n                        <button class=\"gp-sort-lines-button secondary\" onclick=\"downloadResult()\">\n                            \ud83d\udcbe Download\n                        <\/button>\n                        <button class=\"gp-sort-lines-button secondary\" onclick=\"copyToInput()\">\n                            \u2b05\ufe0f Copy to Input\n                        <\/button>\n                    <\/div>\n                <\/div>\n            <\/div>\n\n            <!-- Statistics -->\n            <div class=\"gp-sort-lines-stats\">\n                <h2>\ud83d\udcca Statistics<\/h2>\n                <div class=\"gp-sort-lines-stats-grid\">\n                    <div class=\"gp-sort-lines-stat\">\n                        <span class=\"gp-sort-lines-stat-number\" id=\"totalLines\">0<\/span>\n                        <span class=\"gp-sort-lines-stat-label\">Total Lines<\/span>\n                    <\/div>\n                    <div class=\"gp-sort-lines-stat\">\n                        <span class=\"gp-sort-lines-stat-number\" id=\"uniqueLines\">0<\/span>\n                        <span class=\"gp-sort-lines-stat-label\">Unique Lines<\/span>\n                    <\/div>\n                    <div class=\"gp-sort-lines-stat\">\n                        <span class=\"gp-sort-lines-stat-number\" id=\"duplicateLines\">0<\/span>\n                        <span class=\"gp-sort-lines-stat-label\">Duplicates<\/span>\n                    <\/div>\n                    <div class=\"gp-sort-lines-stat\">\n                        <span class=\"gp-sort-lines-stat-number\" id=\"emptyLines\">0<\/span>\n                        <span class=\"gp-sort-lines-stat-label\">Empty Lines<\/span>\n                    <\/div>\n                    <div class=\"gp-sort-lines-stat\">\n                        <span class=\"gp-sort-lines-stat-number\" id=\"totalChars\">0<\/span>\n                        <span class=\"gp-sort-lines-stat-label\">Characters<\/span>\n                    <\/div>\n                    <div class=\"gp-sort-lines-stat\">\n                        <span class=\"gp-sort-lines-stat-number\" id=\"avgLength\">0<\/span>\n                        <span class=\"gp-sort-lines-stat-label\">Avg Length<\/span>\n                    <\/div>\n                <\/div>\n            <\/div>\n\n            <!-- Operation History -->\n            <div class=\"gp-sort-lines-history\">\n                <h2>\ud83d\udcda Operation History<\/h2>\n                <div id=\"historyContainer\">\n                    <p style=\"color: #000; font-weight: 700; text-align: center; padding: 20px;\">No operations performed yet<\/p>\n                <\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Toast Notification -->\n        <div class=\"gp-sort-lines-toast\" id=\"toast\"><\/div>\n    <\/div>\n\n    <script>\n        \/\/ Global variables\n        let history = [];\n        let historyIndex = -1;\n        let operationHistory = [];\n        \n        \/\/ Rotating tips\n        const tips = [\n            \"Perfect for organizing lists, bibliographies, contact information, and any text that needs alphabetical ordering.\",\n            \"Use 'Remove Duplicates' to clean up lists with repeated entries automatically.\",\n            \"Try 'Sort by Length' to organize lines from shortest to longest for better readability.\",\n            \"Numerical sorting works great for organizing numbered lists or data with numeric values.\",\n            \"Case insensitive sorting treats 'Apple' and 'apple' the same for natural alphabetical order.\",\n            \"Use 'Random' sorting to shuffle your list items for creative brainstorming or random selection.\",\n            \"The undo\/redo feature lets you experiment with different sorting options without losing your work.\",\n            \"Export your sorted results as a text file for easy sharing and backup.\"\n        ];\n        \n        let currentTipIndex = 0;\n        \n        \/\/ Rotate tips every 5 seconds\n        setInterval(() => {\n            currentTipIndex = (currentTipIndex + 1) % tips.length;\n            document.getElementById('rotatingTip').textContent = tips[currentTipIndex];\n        }, 5000);\n\n        \/\/ Initialize\n        document.addEventListener('DOMContentLoaded', function() {\n            const inputText = document.getElementById('inputText');\n            inputText.addEventListener('input', updateStats);\n            inputText.addEventListener('input', debounce(autoSort, 500));\n            \n            \/\/ Load sample data\n            inputText.value = `Zebra\nApple\nBanana\nCherry\nElderberry\nDate\nFig\nGrape\nKiwi\nLemon`;\n            updateStats();\n            sortLines();\n        });\n\n        \/\/ Debounce function\n        function debounce(func, wait) {\n            let timeout;\n            return function executedFunction(...args) {\n                const later = () => {\n                    clearTimeout(timeout);\n                    func(...args);\n                };\n                clearTimeout(timeout);\n                timeout = setTimeout(later, wait);\n            };\n        }\n\n        \/\/ Auto-sort on input change\n        function autoSort() {\n            if (document.getElementById('inputText').value.trim()) {\n                sortLines();\n            }\n        }\n\n        \/\/ Main sorting function\n        function sortLines() {\n            const inputText = document.getElementById('inputText').value;\n            const outputText = document.getElementById('outputText');\n            \n            if (!inputText.trim()) {\n                outputText.value = '';\n                updateStats();\n                return;\n            }\n\n            \/\/ Save to history\n            saveToHistory(inputText);\n            \n            let lines = inputText.split('\\n');\n            const originalCount = lines.length;\n            \n            \/\/ Remove empty lines if option is checked\n            if (document.getElementById('removeEmpty').checked) {\n                lines = lines.filter(line => line.trim() !== '');\n            }\n            \n            \/\/ Remove duplicates if option is checked\n            if (document.getElementById('removeDuplicates').checked) {\n                lines = [...new Set(lines)];\n            }\n            \n            const sortBy = document.getElementById('sortBy').value;\n            const caseInsensitive = document.getElementById('caseInsensitive').checked;\n            const reverseOrder = document.getElementById('reverseOrder').checked;\n            \n            \/\/ Sort based on selected method\n            switch (sortBy) {\n                case 'alphabetical':\n                    lines.sort((a, b) => {\n                        const aVal = caseInsensitive ? a.toLowerCase() : a;\n                        const bVal = caseInsensitive ? b.toLowerCase() : b;\n                        return aVal.localeCompare(bVal);\n                    });\n                    break;\n                case 'length':\n                    lines.sort((a, b) => a.length - b.length);\n                    break;\n                case 'numerical':\n                    lines.sort((a, b) => {\n                        const numA = parseFloat(a) || 0;\n                        const numB = parseFloat(b) || 0;\n                        return numA - numB;\n                    });\n                    break;\n                case 'random':\n                    for (let i = lines.length - 1; i > 0; i--) {\n                        const j = Math.floor(Math.random() * (i + 1));\n                        [lines[i], lines[j]] = [lines[j], lines[i]];\n                    }\n                    break;\n            }\n            \n            \/\/ Reverse if option is checked\n            if (reverseOrder && sortBy !== 'random') {\n                lines.reverse();\n            }\n            \n            outputText.value = lines.join('\\n');\n            updateStats();\n            \n            \/\/ Add to operation history\n            const operation = {\n                type: `Sort ${sortBy}${reverseOrder ? ' (reversed)' : ''}`,\n                timestamp: new Date().toLocaleTimeString(),\n                inputLines: originalCount,\n                outputLines: lines.length,\n                originalText: inputText\n            };\n            addToOperationHistory(operation);\n            \n            showToast('Lines sorted successfully!');\n        }\n\n        \/\/ Update statistics\n        function updateStats() {\n            const inputText = document.getElementById('inputText').value;\n            const outputText = document.getElementById('outputText').value;\n            \n            const inputLines = inputText ? inputText.split('\\n') : [];\n            const outputLines = outputText ? outputText.split('\\n') : [];\n            \n            const nonEmptyLines = inputLines.filter(line => line.trim() !== '');\n            const uniqueLines = [...new Set(nonEmptyLines)];\n            const duplicates = nonEmptyLines.length - uniqueLines.length;\n            const emptyLines = inputLines.length - nonEmptyLines.length;\n            const totalChars = inputText.length;\n            const avgLength = nonEmptyLines.length > 0 ? Math.round(totalChars \/ nonEmptyLines.length) : 0;\n            \n            \/\/ Animate number changes\n            animateNumber('totalLines', inputLines.length);\n            animateNumber('uniqueLines', uniqueLines.length);\n            animateNumber('duplicateLines', duplicates);\n            animateNumber('emptyLines', emptyLines);\n            animateNumber('totalChars', totalChars);\n            animateNumber('avgLength', avgLength);\n        }\n\n        \/\/ Animate number changes\n        function animateNumber(elementId, newValue) {\n            const element = document.getElementById(elementId);\n            const currentValue = parseInt(element.textContent) || 0;\n            \n            if (currentValue !== newValue) {\n                element.classList.add('gp-sort-lines-pulse');\n                setTimeout(() => {\n                    element.textContent = newValue;\n                    element.classList.remove('gp-sort-lines-pulse');\n                }, 250);\n            }\n        }\n\n        \/\/ Copy to clipboard\n        async function copyToClipboard() {\n            const outputText = document.getElementById('outputText').value;\n            if (!outputText) {\n                showToast('Nothing to copy!', 'error');\n                return;\n            }\n            \n            try {\n                await navigator.clipboard.writeText(outputText);\n                showToast('Copied to clipboard!');\n            } catch (err) {\n                \/\/ Fallback for older browsers\n                const textarea = document.getElementById('outputText');\n                textarea.select();\n                document.execCommand('copy');\n                showToast('Copied to clipboard!');\n            }\n        }\n\n        \/\/ Download result\n        function downloadResult() {\n            const outputText = document.getElementById('outputText').value;\n            if (!outputText) {\n                showToast('Nothing to download!', 'error');\n                return;\n            }\n            \n            const blob = new Blob([outputText], { type: 'text\/plain' });\n            const url = URL.createObjectURL(blob);\n            const a = document.createElement('a');\n            a.href = url;\n            a.download = 'sorted-lines.txt';\n            document.body.appendChild(a);\n            a.click();\n            document.body.removeChild(a);\n            URL.revokeObjectURL(url);\n            \n            showToast('File downloaded!');\n        }\n\n        \/\/ Copy output to input\n        function copyToInput() {\n            const outputText = document.getElementById('outputText').value;\n            if (!outputText) {\n                showToast('Nothing to copy!', 'error');\n                return;\n            }\n            \n            document.getElementById('inputText').value = outputText;\n            updateStats();\n            showToast('Copied to input!');\n        }\n\n        \/\/ Clear input\n        function clearInput() {\n            const inputText = document.getElementById('inputText');\n            saveToHistory(inputText.value);\n            inputText.value = '';\n            document.getElementById('outputText').value = '';\n            updateStats();\n            showToast('Input cleared!');\n        }\n\n        \/\/ History management\n        function saveToHistory(text) {\n            if (text && (history.length === 0 || history[history.length - 1] !== text)) {\n                history.push(text);\n                historyIndex = history.length - 1;\n                \n                \/\/ Keep only last 20 entries\n                if (history.length > 20) {\n                    history.shift();\n                    historyIndex--;\n                }\n            }\n        }\n\n        \/\/ Undo action\n        function undoAction() {\n            if (historyIndex > 0) {\n                historyIndex--;\n                document.getElementById('inputText').value = history[historyIndex];\n                updateStats();\n                sortLines();\n                showToast('Undo successful!');\n            } else {\n                showToast('Nothing to undo!', 'error');\n            }\n        }\n\n        \/\/ Redo action\n        function redoAction() {\n            if (historyIndex < history.length - 1) {\n                historyIndex++;\n                document.getElementById('inputText').value = history[historyIndex];\n                updateStats();\n                sortLines();\n                showToast('Redo successful!');\n            } else {\n                showToast('Nothing to redo!', 'error');\n            }\n        }\n\n        \/\/ Add to operation history\n        function addToOperationHistory(operation) {\n            operationHistory.unshift(operation);\n            \n            \/\/ Keep only last 10 operations\n            if (operationHistory.length > 10) {\n                operationHistory.pop();\n            }\n            \n            updateOperationHistoryDisplay();\n        }\n\n        \/\/ Update operation history display\n        function updateOperationHistoryDisplay() {\n            const container = document.getElementById('historyContainer');\n            \n            if (operationHistory.length === 0) {\n                container.innerHTML = '<p style=\"color: #000; font-weight: 700; text-align: center; padding: 20px;\">No operations performed yet<\/p>';\n                return;\n            }\n            \n            container.innerHTML = operationHistory.map(op => `\n                <div class=\"gp-sort-lines-history-item\">\n                    <div class=\"gp-sort-lines-history-text\">\n                        ${op.type} at ${op.timestamp} (${op.inputLines} \u2192 ${op.outputLines} lines)\n                    <\/div>\n                    <button class=\"gp-sort-lines-history-restore\" onclick=\"restoreFromHistory('${op.originalText.replace(\/'\/g, \"\\\\'\")}')\">\n                        Restore\n                    <\/button>\n                <\/div>\n            `).join('');\n        }\n\n        \/\/ Restore from history\n        function restoreFromHistory(text) {\n            document.getElementById('inputText').value = text.replace(\/\\\\'\/g, \"'\");\n            updateStats();\n            sortLines();\n            showToast('Restored from history!');\n        }\n\n        \/\/ Show toast notification\n        function showToast(message, type = 'success') {\n            const toast = document.getElementById('toast');\n            toast.textContent = message;\n            toast.className = `gp-sort-lines-toast show ${type}`;\n            \n            setTimeout(() => {\n                toast.classList.remove('show');\n            }, 3000);\n        }\n\n        \/\/ Keyboard shortcuts\n        document.addEventListener('keydown', function(e) {\n            if (e.ctrlKey || e.metaKey) {\n                switch (e.key) {\n                    case 'Enter':\n                        e.preventDefault();\n                        sortLines();\n                        break;\n                    case 'z':\n                        if (e.shiftKey) {\n                            e.preventDefault();\n                            redoAction();\n                        } else {\n                            e.preventDefault();\n                            undoAction();\n                        }\n                        break;\n                    case 'k':\n                        e.preventDefault();\n                        clearInput();\n                        break;\n                }\n            }\n        });\n    <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Sort Lines Alphabetically Tool A\u2192Z Sort Lines Alphabetically Organize your text lines in perfect alphabetical order with advanced sorting options &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Sort Lines Alphabetically\" class=\"read-more button\" href=\"https:\/\/vijaypandit.in\/?page_id=331#more-331\" aria-label=\"More on Sort Lines Alphabetically\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-331","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/vijaypandit.in\/index.php?rest_route=\/wp\/v2\/pages\/331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vijaypandit.in\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/vijaypandit.in\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/vijaypandit.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vijaypandit.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331"}],"version-history":[{"count":1,"href":"https:\/\/vijaypandit.in\/index.php?rest_route=\/wp\/v2\/pages\/331\/revisions"}],"predecessor-version":[{"id":332,"href":"https:\/\/vijaypandit.in\/index.php?rest_route=\/wp\/v2\/pages\/331\/revisions\/332"}],"wp:attachment":[{"href":"https:\/\/vijaypandit.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}