From: Dave Bass Date: 2009-01-12T21:00:05+09:00 Subject: Re: sort hash, hash key and val off by one, see attached Mmcolli00 Mom wrote: > I just need to somehow find the next key in a hash I haven't read your example, but this statement rings alarm bells. You need to define what you mean by "the next key". A hash has no natural ordering -- it's just a bunch of key-value pairs -- so it's not obvious what the "next" key means. The order in which you insert pairs is not necessarily the order in which you get them back, and this order may vary from one run to the next. This is basic to hashes. If you don't mind the order in which the keys are processed, you can use "each" to iterate through the hash. As a quick fix, you could get all the keys into an array and sort them into the order you want (alphabetically, numerically, etc). Dave -- Posted via http://www.ruby-forum.com/.