jospan has asked for the wisdom of the Perl Monks concerning the following question:
Oh Elders of Perldom, Wizards of Code and Masters of the Divine Editor enligthen a simple novice please! :)
I have an array (hereafter known as The Master Array).
The array is sorted.
I produce new arrays as subsets of The Master Array by using grep.
My question(s) is this:
1) will the subset arrays still be sorted as The Master Array or will I have to re-sort the subset arrays if I wish to ensure that these are sorted?
2) Whatever the answer to 1): can the answer be generalized to all cases where a function (say map) is used to produce arrays from a sorted master array?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Will the sorting order of an array used in producing new arrays be retained?
by hippo (Bishop) on Oct 09, 2012 at 21:21 UTC | |
Re: Will the sorting order of an array used in producing new arrays be retained?
by AnomalousMonk (Archbishop) on Oct 09, 2012 at 22:24 UTC | |
by jospan (Novice) on Oct 09, 2012 at 22:56 UTC | |
Re: Will the sorting order of an array used in producing new arrays be retained?
by linuxkid (Sexton) on Oct 09, 2012 at 22:53 UTC | |
by jospan (Novice) on Oct 09, 2012 at 23:01 UTC |
Back to
Seekers of Perl Wisdom