Posts

Showing posts from 2019

Hacker Rank problem solution

1. Sort Item based on the  column  : - ( void ) viewDidLoad {     [ super viewDidLoad ];     // Do any additional setup after loading the view, typically from a nib.     NSArray *ary = [ self fetchItemsToDisplay : @[ @"Item4,10,15" , @"Item2,3,4" , @"Item3,17,8" ] sortParameter : @(1) sortOrder : @(0) itemPerPage : @(2) pageNumber : @(1) ];     NSLog ( @"%@" ,ary);      } - ( NSArray *) fetchItemsToDisplay :( NSArray *)items sortParameter :( NSNumber *)sortParameter sortOrder :( NSNumber *)sortOrder itemPerPage :( NSNumber *)itemPerPage pageNumber :( NSNumber *)pageNumber {          NSMutableArray *itemArray = [ NSMutableArray new ];          for ( int i = 0 ; i<items. count ; i++) {         NSString *item = items[i];         NSArray *itemDetails = [item componentsSeparatedByString : @"," ];                  ItemModel *itemModel = [[ ItemModel alloc ] init ];