# Tie::Array::Sorted::Lazy - An array which is kept sorted - perldoc - [phpMan]

## NAME
    [Tie::Array::Sorted::Lazy](https://www.chedong.com/phpMan.php/perldoc/Tie%3A%3AArray%3A%3ASorted%3A%3ALazy/markdown) - An array which is kept sorted

## SYNOPSIS
            use [Tie::Array::Sorted::Lazy](https://www.chedong.com/phpMan.php/perldoc/Tie%3A%3AArray%3A%3ASorted%3A%3ALazy/markdown);

            tie @a, "[Tie::Array::Sorted::Lazy](https://www.chedong.com/phpMan.php/perldoc/Tie%3A%3AArray%3A%3ASorted%3A%3ALazy/markdown)", sub { $_[0] <=> $_[1] };

            push @a, 10, 4, 7, 3, 4;
            print "@a"; # "3 4 4 7 10"

## DESCRIPTION
    This is a version [Tie::Array::Sorted](https://www.chedong.com/phpMan.php/perldoc/Tie%3A%3AArray%3A%3ASorted/markdown) optimised for arrays which are stored to more often than
    fetching. In this case the array is resorted on retrieval, rather than insertion. (It only
    re-sorts if data has been modified since the last sort).

            tie @a, "[Tie::Array::Sorted::Lazy](https://www.chedong.com/phpMan.php/perldoc/Tie%3A%3AArray%3A%3ASorted%3A%3ALazy/markdown)", sub { -s $_[0] <=> -s $_[1] };

