From: Robert Klemme Date: 2009-04-03T17:39:32+09:00 Subject: Re: An array problem On 03.04.2009 10:17, George George wrote: > Robert Klemme wrote: > >> I don't see how the order in a could not be preserved. Please check >> again oder provide full code. > > Here is the code > #original list > @list_of_names > > #mcl.total_clusters provides a count for the number of clusters #or > arrays available(a.k.a, my b and c in the previous #descriptions) > > #an iterator that counts the number of arrays available(subsets #of > @cluster_members > mcl.total_clusters.times do |i| > cluster_members = mcl.cluster_members_for(i) > > @list_of_names.each do |el| > case > when cluster_members.include?(el) > puts "#{el} - #{i}" > end > end > end > > Given: @list_of_names = > [10Atig18,10Atig8,10Atig7,10Atig3,10Btig15,10Btig11,10Btig1], > > > and cluster b=[10Atig8,10Atig3,10Btig1] while the rest of the members > belonged to cluster c > > produce a report such that > 10Atig18 -c > 10Atig8 -b > 10Atig7 -c > 10Atig3 -b > 10Btig15 -c > 10Btig11 -c > 10Btig1 -b > > The implementation above produces this, > 10Atig8 -b > 10Atig3 -b > 10Btig1 -b > 10Atig18 -c > 10Atig7 -c > 10Btig15 -c > 10Btig11 -c > > which is not what is required. George, you claimed that the code *I* presented does not maintain order. Now you present totally different code as "proof". The error is in *your* code. Btw, you also did not state that the number of cluster arrays (b and c) is not fixed which is of course why you could not use the bit you claimed would not maintain order. Please go back to my original posting - you'll find building blocks for a solution there. I'll leave the rest to you. Regards robert