-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?

iYousafzai
  • 1,021
  • 1
  • 10
  • 29

1 Answers1

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.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57