Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Hint for the day: .keys.sort

Reply
Thread Tools

Hint for the day: .keys.sort

 
 
John Carter
Guest
Posts: n/a
 
      03-02-2004
I often have cause to refer to .keys of a hash, or .each_pair

But, unsurprisingly given the nature of a Hash, the values come out in
random order.

This means my programs do things in a very different order depending on
the tiniest change.

99.9999% of the cases it doesn't matter, but it disturbs my users. For
user X, things come in this order, for user Y it comes out in a completely
different order. This makes them worry.

It really doesn't matter, but it worries them.

If your user ever possibly sees the output of .keys in any form, get
into the habit of saying .keys.sort instead.

It just soothes them and makes your users feel warm and fuzzy.



John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : http://www.velocityreviews.com/forums/(E-Mail Removed)
New Zealand

Note to all marketers. If you want to sell things to me, buy Google words.

I refuse on principle to buy anything sold by spam or popup and I
never follow any links found in a spam. I do however use Google and
will often follow the neat non-irritating Google Word ads that are of
interest to me.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PIX VPN debugging hint Walter Roberson Cisco 0 10-18-2005 04:56 AM
How to create a hint? Marek ASP .Net 5 12-27-2004 04:13 PM
can anyone give me a hint Robert MCSD 0 08-11-2004 05:49 PM
[Eclipse] Another hint..required ShadowMan Java 5 06-11-2004 02:12 PM
More confused than ever. Please give me a hint. Daniel Pope Java 5 02-22-2004 04:20 PM



Advertisments