Keep in mind [] != []
Array.unique is not recursive, it's for flat lists. You'll have to filter things out on your own some how. No language's unique array method that I have ever used drills down a multi-dimensional array and compares it's elements to elements in the siblings of it's parents and friend's cousin's dog like you're trying to do :) On Sep 27, 2010, at 12:10 PM, [email protected] wrote: > i cant flatten this, sorry. i need an array of elements (tasks), > according to my html markup. > > <taskgroup> > <task 1> > <task 2> > <task 3> > </taskgroup> > <task 4> > <task 5> > > should become: [ [ task1, task2, task3 ], task4, task5 ]. my code > looks as follows: > > $$('.task').each( function(item) { > > // this shows me, that a taskgroup starts > > if ( item.hasClass('taskgroup-title') ) { > > var array = []; > > array.push(item.get('id')); > > item.getAllNext('.task').each( > function(sub_item) { > if ( > !self.options.tasksArray.contains(sub_item.get('id')) ) > array.push(sub_item.get('id')); > }); > > self.options.tasksArray.push(array); > > self.options.tasksArray.erase(array); > > } else { > var id = item.get('id'); > if ( !self.options.tasksArray.contains( id ) ) > self.options.tasksArray.push(item.get('id')); > } > > }); > > On 27 Sep., 19:53, Ryan Florence <[email protected]> wrote: >> Array.flatten first. >> >> On Sep 27, 2010, at 11:31 AM, [email protected] wrote: >> >>> im cuurently wondering if array.unique() wont work with >>> multidimensional arrays. my array: >> >>> [ ["task-1", "task-2"], "task-2", "task-112", "task-108", "task-113", >>> "task-109", "task-114", "task-54", "task-55", "task-58", "task-59", >>> "task-107", "task-110", "task-111" ] >> >>> won't cleaned up. you notice the double-appearance of "task-2".
