j = 1 while (j <= 3) hash = (null) test list = (null) for each item in master category list if category is a 'Level j' add category to test list endif endfor for each data record get record category, record data for each test category if record category matches test category at level 'j' hash{test category} += record data endif endfor endfor foreach key in hash output hash(key) endfor j += 1 endwhile