- (NSMutableArray *)compareList:(NSMutableArray *)list IS_UP:(BOOL)isUp IS_PRICE:(BOOL)isPrice
{
NSMutableArray *finalList = [[[NSMutableArray alloc] init] autorelease];
if (isPrice == YES) {
NSMutableArray *RecommandCloth_list = [[NSMutableArray alloc] initWithArray:list];
int count = RecommandCloth_list.count;
NSLog(@"count:%d",count);
RecommandClothItem * tempRecommand_small;
RecommandClothItem * tempRecommand;
while (RecommandCloth_list.count > 0) {
tempRecommand_small = [RecommandCloth_list objectAtIndex:0];
for (int i=1; i<RecommandCloth_list.count; i++) {
tempRecommand = [RecommandCloth_list objectAtIndex:i];
NSLog(@"tempRecommand.price:%@",tempRecommand.price);
NSLog(@"tempRecommand_small.price:%@",tempRecommand_small.price);
if (isUp == YES) {
if (tempRecommand.price.intValue < tempRecommand_small.price.intValue) {
tempRecommand_small = tempRecommand;
}
}
else {
if (tempRecommand.price.intValue > tempRecommand_small.price.intValue) {
tempRecommand_small = tempRecommand;
}
}
}
[finalList addObject:tempRecommand_small];
for (int j = 0; j<RecommandCloth_list.count;j++) {
RecommandClothItem *temp_RecommandClothItem = [RecommandCloth_list objectAtIndex:j];
if ([tempRecommand_small.recommandCloth_id isEqualToString:temp_RecommandClothItem.recommandCloth_id]) {
[RecommandCloth_list removeObject:temp_RecommandClothItem];
}
}
NSLog(@"RecommandCloth_list.count:%d",RecommandCloth_list.count);
}
}
else{
NSMutableArray *RecommandCloth_list = [[NSMutableArray alloc] initWithArray:list];
int count = RecommandCloth_list.count;
NSLog(@"count:%d",count);
RecommandClothItem * tempRecommand_small;
RecommandClothItem * tempRecommand;
while (RecommandCloth_list.count > 0) {
tempRecommand_small = [RecommandCloth_list objectAtIndex:0];
for (int i=1; i<RecommandCloth_list.count; i++) {
tempRecommand = [RecommandCloth_list objectAtIndex:i];
NSLog(@"tempRecommand.price:%@",tempRecommand.price);
NSLog(@"tempRecommand_small.price:%@",tempRecommand_small.price);
if (isUp == YES) {
if (tempRecommand.sales_volume.intValue < tempRecommand_small.sales_volume.intValue) {
tempRecommand_small = tempRecommand;
}
}
else {
if (tempRecommand.sales_volume.intValue > tempRecommand_small.sales_volume.intValue) {
tempRecommand_small = tempRecommand;
}
}
}
[finalList addObject:tempRecommand_small];
for (int j = 0; j<RecommandCloth_list.count;j++) {
RecommandClothItem *temp_RecommandClothItem = [RecommandCloth_list objectAtIndex:j];
if ([tempRecommand_small.recommandCloth_id isEqualToString:temp_RecommandClothItem.recommandCloth_id]) {
[RecommandCloth_list removeObject:temp_RecommandClothItem];
}
}
NSLog(@"RecommandCloth_list.count:%d",RecommandCloth_list.count);
}
}
return finalList;
}