On Mar 3, 2006, at 1:12 PM, Julian Gall wrote: > Stephen Waits wrote: >> Maybe you could post an irb session of your own so we could see >> what's happening? > > Not really possible. I am writing a Rails application with a sortable > list on a web page. An XML_Http_request serialises the ids of the list > items and POSTs them to my action controller. By the time I see this > data it is an array of identifiers (numbers) in params[:itemlist]. > > I extract this to a local array with: > > new_item_ids = [] > params[:itemlist].each {|item| new_item_ids << item} > > I want to compare this with another local array of my original > (unsorted) identifiers. i.e. > > original_item_ids.sort <=> new_item_ids.sort > > This doesn't work, although this does: > > original_item_ids.sort.join('-') == new_item_ids.sort.join('-') > > It is odd that join works to produce the expected string where <=> > thinks it has a problem. > > Julian > > -- > Posted via http://www.ruby-forum.com/. > Based on join working this is my theory. One of the two arrays have nil's in it. nil.to_s is "" but nil <=> anything save nil is nil and will cause the comparision to fail.