I have an NSMutableArray(ArrayOne) structured like so..
({
"item_image_timeStamp" = "492364855.234597";
"item_image_url" = "sample url";
"item_image_vote" = 123;
}, {
"item_image_timeStamp" = "492364458.236597";
"item_image_url" = "sample url";
"item_image_vote" = 456;
}, {
"item_image_timeStamp" = "492364179.052397";
"item_image_url" = "sample url";
"item_image_vote" = 6184;
}, {
"item_image_timeStamp" = "492364789.004447";
"item_image_url" = "sample url";
"item_image_vote" = 64;
}, {
"item_image_timeStamp" = "492364356.002341";
"item_image_url" = "sample url";
"item_image_vote" = 3778;
})
The maximum number of objects that can be contained in ArrayOne is 10.
Then, I have a second NSMutableArray(ArrayTwo) structured just like ArrayOne
({
"item_image_timeStamp" = "492364855.234597";
"item_image_url" = "sample url";
"item_image_vote" = 123;
}, {
"item_image_timeStamp" = "492364458.236597";
"item_image_url" = "sample url";
"item_image_vote" = 456;
})
..except that the maximum number of objects that can be contained in ArrayTwo is 3.
Now, What I want to do is..
- add objects of ArrayTwo into ArrayOne (keeping in mind that ArrayOne can only hold a maximum of 10 objects)
- keep the top 5 objects sorted by the key "item_image_vote" (top five voted object should not be replaced)
- if any objects in ArrayOne need to be replaced, item with the lowest value for key "item_image_timeStamp" should be replaced first.(oldest object will be replaced first..followed by the the second oldest).
I hope I did not make my question too confusing. Thank you in advance.