Ruby array of arrays find by inner array value -
i have array of arrays, looks this:
a = [['1','1500','somename','somesurname'], ['2','1500','somename2','somesurname2'], ['3','1500','somename3','somesurname3'], ['4','1501','somename','somesurname'], ...]
i can sub-array of array rows containing '1500' value .each
function , simple if
, if a.length
large, it's taking time! how can rows a
a[1]
value, without iterating on a
?
enumerable#find_all
looking for:
a.find_all { |el| el[1] == '1500' } # a.select same
Comments
Post a Comment