# Nested array filling well.. but tricky search back

**URL:** <https://www.ruby-forum.com/t/nested-array-filling-well-but-tricky-search-back/115360>\
**Category:** Ruby\
**Created:** [September 24, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/nested-array-filling-well-but-tricky-search-back/115360 "2007-09-24T13:00:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josselin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@Josselin](https://www.ruby-forum.com/u/Josselin)\
**Post date:** [September 24, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/nested-array-filling-well-but-tricky-search-back/115360/1 "2007-09-24T13:00:46Z")

</div>

thanks to your help…

I got a nice nested array

ALL\_CATEGORIES = [[[1, “category1”], [2, “category2”], [3,  
“category3”], [4, “category4”]], [[5, “category5”], [6, “category6”],  
[7, “category7”], [8, “category8”]], [[9, “category9”], [10,  
“category10”], [11, “category11”], [12, “category12”], [13,  
“category13”], [14, “category14”], [15, “category15”]], [[16,  
“category16”], [17, “category17”], [18, “category18”], [19,  
“category19”]], [[20, “category20”], [21, “category21”], [22,  
“category22”]], [[23, “category23”], [24, “category24”], [25,  
“category25”], [26, “category26”], [27, “category27”], [28,  
“category28”]], [[29, “category29”], [30, “category30”], [31,  
“category31”]

so I can get :  
all categories of first domain  
ALL\_CATEGORIES[0] =\> [[1, “category1”], [2, “category2”], [3,  
“category3”], [4, “category4”]]  
first category of first domain  
ALL\_CATEGORIES[0][0] =\> [1, “category1”]  
category index of first category of first domain  
ALL\_CATEGORIES[0][0][0] =\> 1  
category label of first category of first domain  
ALL\_CATEGORIES[0][0][1] =\> “category1”

is there any easy way to find back the domain index from the category  
index ? or should I rewrite my array ?

given category index 5 then domain index would be 1  
I would find it in ALL\_CATEGORIES[1] =\> [[5, “category5”], [6,  
“category6”], [7, “category7”], [8, “category8”]]

thanks fyh

joss
