{
    "mode": "perldoc",
    "parameter": "sort",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/sort/json",
    "generated": "2026-08-09T06:40:34Z",
    "synopsis": "The sort pragma is now a no-op, and its use is discouraged. These three operations are valid,\nbut have no effect:\nuse sort 'stable';          # guarantee stability\nuse sort 'defaults';        # revert to default behavior\nno  sort 'stable';          # stability not important",
    "sections": {
        "NAME": {
            "content": "sort - perl pragma to control sort() behaviour\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "The sort pragma is now a no-op, and its use is discouraged. These three operations are valid,\nbut have no effect:\n\nuse sort 'stable';          # guarantee stability\nuse sort 'defaults';        # revert to default behavior\nno  sort 'stable';          # stability not important\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Historically the \"sort\" pragma you can control the behaviour of the builtin sort() function.\n\nPrior to v5.28.0 there were two other options:\n\nuse sort 'mergesort';\nuse sort 'qsort';          # or 'quicksort'\n\nIf you try and specify either of these in v5.28+ it will croak.\n\nThe default sort has been stable since v5.8.0, and given this consistent behaviour for almost\ntwo decades, everyone has come to assume stability.\n\nStability will remain the default - hence there is no need for a pragma for code to opt into\nstability \"just in case\" this changes - it won't.\n\nWe do not foresee going back to offering multiple implementations of general purpose sorting -\nhence there is no future need to offer a pragma to choose between them.\n\nIf you know that you care that much about performance of your sorting, and that for your use\ncase and your data, it was worth investigating alternatives, possible to identify an alternative\nfrom our default that was better, and the cost of switching was worth it, then you know more\nthan we do. Likely whatever choices we can give are not as good as implementing your own. (For\nexample, a Radix sort can be faster than O(n log n), but can't be used for all keys and has\nlarger overheads.)\n\nWe are not averse to changing the sort algorithm, but we don't see the benefit in offering the\nchoice of two general purpose implementations.\n",
            "subsections": []
        },
        "CAVEATS": {
            "content": "The function sort::current() was provided to report the current state of the sort pragmata. This\nfunction was not exported, and there is no code to call it on CPAN. It is now deprecated, and\nwill warn by default.\n\nAs we no longer store any sort \"state\", it can no longer return the correct value, so it will\nalways return the string \"stable\", as this is consistent with what we actually have implemented.\n",
            "subsections": []
        }
    },
    "summary": "sort - perl pragma to control sort() behaviour",
    "flags": [],
    "examples": [],
    "see_also": []
}