-1

I have this array1 which contains dictionaries like this:

array1:  (
    {
   ordering = 18;
},
    {
   ordering = 22;
}
)

and i have array2 which contains arrays of dictionaries like this:

array2: (
    (
            {
             ordering = 17;
  },
   {
             ordering = 29;
}
),
    (
            {
            ordering = 23;
      }
   )
)

Now i want to insert the first array from array2({ordering=17}) before the dictionary with {ordering=18} and the second array from array2({ordering=23}) after the dictionary {ordering=22} in array1.Something like this:

array1=( 
    (
            {
             ordering = 17;
      },
 {
         ordering = 29;
 }
),
   {
   ordering = 22;
 },
  (
            {
            ordering = 23;
        }
     )
)

Can this be done?Please let me know if anyone knows how to do this?

3
  • Can this be done? YES, Please let me know if anyone knows how to do this? stackoverflow.com/questions/7001597/… Commented Aug 25, 2014 at 12:25
  • Please check my edited question.i don't think sortDescriptor will give the exact result i want no? Commented Aug 25, 2014 at 12:31
  • 1
    This style must be called "devils indentation". Commented Aug 25, 2014 at 13:22

1 Answer 1

1

The easiest way is probably to do it in two steps. Use insertObjectsFromArray: to put the new ones at the end of the existing array and then sortUsingComparator: to order them.

Sign up to request clarification or add additional context in comments.

2 Comments

Please check my edited question the exact result i want in array1.sorting will change that order too no?
When you write the comparator block it will use any logic you give it to decide the ordering.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.