Chinese sort haha

Source: Internet
Author: User

////main.m//before 1////Created by Syrcfwzx on 16/1/11.//Copyright (c) 2016 SYRCFWZX. All rights reserved.//#import<Foundation/Foundation.h>#defineNSLog (FORMAT, ...) printf ("%s\n", [[NSString Stringwithformat:format, # #__VA_ARGS__] utf8string])intMainintargcConst Char*argv[]) {@autoreleasepool {/*The 1th question please store the following data into a dictionary, and the dictionary content as a string output, output: "xxx, age xxx, subject xxx, score xxx" (replace XXX with the corresponding data). */NSString*name =@"Zhang San"; Nsinteger Age= A; NSNumber*[email protected]88.7; NSString*subject =@"Mathematics"; Nsdictionary*dic = @{@"name": Name,@" Age": @ (age),@"score": Score,@"subject": Subject}; NSLog (@"%@ %@ %@ %@", dic[@"name"],dic[@" Age"],dic[@"score"],dic[@"subject"]); /*2nd question: 12,9,34,56,11 deposit Nsarray Array, output: 1) Reverse output 2) descending output*/Nsarray*array = [Nsarray arraywithobjects:@ A,@9,@ the,@ About,@ One, nil]; Nsarray*arr = [Array Sortedarrayusingcomparator:^nscomparisonresult (IDObj2,IDobj1) {            return[Obj1 Compare:obj2];        }]; NSLog (@"%@", arr); Nsarray*ARR2 = [Array sortedarrayusingselector: @selector (class)]; NSLog (@"%@", ARR2); //4th The elements in the array are sorted by Chinese//nsarray *[email protected][@ "Light Rain", @ "Ann", @ "small wind", @ "Rongrong", @ "Zhang Tao" @ "Li Wenrong"]; //nsarray *arrr=[arr sortedarrayusingselector: @selector (localizedstandardcompare:)]; //For (id ser in arrr) {//NSLog (@ "%@", Ser); //        }Nsarray *[email protected][@"Light Rain",@"Ann",@"Xiao Feng",@"Rongrong",@"Zhang Tao",@"Li Wenrong"]; Nsarray*sortarr = [Arr5 sortedarrayusingcomparator:^nscomparisonresult (IDObj1,IDobj2) {            return[Obj1 Localizedcompare:obj2];        }];  for(IDObjinchSortarr) {NSLog (@"%@", obj); }            }    return 0;}

Chinese sort haha

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.