{
    "mode": "perldoc",
    "parameter": "Tie::Array::Sorted",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Tie%3A%3AArray%3A%3ASorted/json",
    "generated": "2026-06-13T21:43:53Z",
    "synopsis": "use Tie::Array::Sorted;\ntie @a, \"Tie::Array::Sorted\", sub { $[0] <=> $[1] };\npush @a, 10, 4, 7, 3, 4;\nprint \"@a\"; # \"3 4 4 7 10\"",
    "sections": {
        "NAME": {
            "content": "Tie::Array::Sorted - An array which is kept sorted\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Tie::Array::Sorted;\n\ntie @a, \"Tie::Array::Sorted\", sub { $[0] <=> $[1] };\n\npush @a, 10, 4, 7, 3, 4;\nprint \"@a\"; # \"3 4 4 7 10\"\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This presents an ordinary array, but is kept sorted. All pushes and unshifts cause the elements\nin question to be inserted in the appropriate location to maintain order.\n\nDirect stores (\"$a[10] = \"wibble\"\") effectively splice out the original value and insert the new\nelement. It's not clear why you'd want to use direct stores like that, but this module does the\nright thing if you do.\n\nIf you don't like the ordinary lexical comparator, you can provide your own; it should compare\nthe two elements it is given. For instance, a numeric comparator would look like this:\n\ntie @a, \"Tie::Array::Sorted\", sub { $[0] <=> $[1] }\n\nWhereas to compare a list of files by their sizes, you'd so something like:\n\ntie @a, \"Tie::Array::Sorted\", sub { -s $[0] <=> -s $[1] }\n",
            "subsections": []
        },
        "LAZY SORTING": {
            "content": "If you do more stores than fetches, you may find Tie::Array::Sorted::Lazy more efficient.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Original author: Simon Cozens\n\nCurrent maintainer: Tony Bowden\n\nBUGS and QUERIES\nPlease direct all correspondence regarding this module to: bug-Tie-Array-Sorted@rt.cpan.org\n\nThis module was originall written as part of the Plucene project. However, as Plucene no longer\nuses this, it is effectively unmaintained.\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (C) 2003-2006 Simon Cozens and Tony Bowden.\n\nThis program is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License; either version 2 of the License,\nor (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\nFOR A PARTICULAR PURPOSE.\n",
            "subsections": []
        }
    },
    "summary": "Tie::Array::Sorted - An array which is kept sorted",
    "flags": [],
    "examples": [],
    "see_also": []
}