Re: [Rails] Can you plz, explain to me part of this code ?

2018-04-30 Thread Abdel Latif
Thank you Rob, I appreciate your help, good explanation. On Thu, Apr 26, 2018 at 5:02 PM, Rob Biedenharn wrote: > > > On 2018-Apr-26, at 13:47 , Abdel Latif wrote: > > But [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]] has non numerical >

Re: [Rails] Can you plz, explain to me part of this code ?

2018-04-26 Thread botp
On Fri, Apr 27, 2018 at 12:12 AM, Abdel Latif wrote: > But this part .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse} > > ​two things look suspicious: 1) /d+/​ ​2) reverse have you tried randomly rearranging your arrays first?​ ​m​ any thanks, --botp -- You received this

Re: [Rails] Can you plz, explain to me part of this code ?

2018-04-26 Thread Rob Biedenharn
> On 2018-Apr-26, at 13:47 , Abdel Latif wrote: > > But [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]] has non numerical > values too. > > On Thursday, April 26, 2018 at 1:05:53 PM UTC-4, Walter Lee Davis wrote: > > > On Apr 26, 2018, at 12:12 PM, Abdel Latif

Re: [Rails] Can you plz, explain to me part of this code ?

2018-04-26 Thread Abdel Latif
But [["AB_1020", "AB_950", "AB_50"], ["1000", "570"]] has non numerical values too. On Thursday, April 26, 2018 at 1:05:53 PM UTC-4, Walter Lee Davis wrote: > > > > On Apr 26, 2018, at 12:12 PM, Abdel Latif > wrote: > > > > Hi, > > > > I found this code for sorting an

Re: [Rails] Can you plz, explain to me part of this code ?

2018-04-26 Thread Walter Lee Davis
> On Apr 26, 2018, at 12:12 PM, Abdel Latif wrote: > > Hi, > > I found this code for sorting an array : > > p ["AB_1020", "AB_950", "AB_50", "1000", "570"].partition{|x| x.to_i.zero? } > .flat_map{|x| x.sort_by {|x|x[/d+/]}.reverse} > ouptut > > #⇒ ["AB_50",