On 13 February 2016 at 10:08, Kent Fredric <kentfred...@gmail.com> wrote:
>
> All you're doing is sorting the *view* of it. Not the data itself.


If you want a demonstration of this fact, on a Linux filesystem, poke
around with 'find'. Or if you've got Path::Iterator::Rule installed:

 perl -MPIR -E' $it = PIR->new->iter_fast(q(.)); while( my $entry =
$it->() ) { say $entry }'

You'll notice that the output frequently /appears/ partly sorted.

But often doesn't seem sorted at all.

tools like 'ls' make this simple for you because they automatically
sort things to display it, but the folder itself is typically not
"sorted", all you've sorted is "a list of files that you retrieved
from a folder"

Similarly, you can "sort" the list of "keys" that come out of a hash,
but you can't sort the hash itself.

my @keys = sort keys %hash;

( Hashes and Filesystems themselves, however, are stored unsorted,
because it is typically faster for the operating system to do it that
way, and then only sort it for presentation purposes when strictly
necessary , because sorting is expensive, so it delays doing it at all
until the very last possible oppotunity )

-- 
Kent

KENTNL - https://metacpan.org/author/KENTNL

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to