Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
Get values from hash "in order"
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jürgen Exner, post: 4847826"] still just me wrote: [about hashes] Actually the order in which e.g. each() or keys() cycles through the items of a hash is not random at all but it is well defined and guaranteed to be the same for every access to that hash. It is just that this sequence doesn't make any sense to the programmer because this sequence is -as you suspected- based on the internal implementation and not on some human expectation about useful order. However, on an abstract level, hashes are a generalization of arrays. Arrays are mappings from natural numbers (assuming you didn't mess with $[) into scalars while hashes are mappings from arbitrary strings into scalars. Natural numbers have an inherent sequence, there is a natural next and previous. Therefore you can specify a concrete point in the array and from there access the next and the previous element. There is no such obvious sequence for strings. Alphabetical sorting is not compact, i.e. between any two given strings there is always another string. And incremental strings as produced by the ++ operator are not what people would expect from a sorted hash. And because there is no such obvious order on the domain elements of hashes as is are the natural numbers for arrays it doesn't make sense to speak of a sequence of the elements of hashes. Sequence of order is foreign to hashes. jue [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Get values from hash "in order"
Top