ios - How to sort Json value in NSDictionary Objective c? -
i want sort nested json array location_name, json in nsdictionary
json array is
apiresult:{ description = "list of location"; code = 200; locationlist = ( { "location_id" = 481; "location_name" = "<null>"; "pre_fixied" = "$3.00"; "state_name" = melbourne; status = 0; zone = "zone 2"; "zone_id" = 30; }, { "location_id" = 461; "location_name" = "o'halloran hill"; "pre_fixied" = "$5.00"; "state_name" = adelaide; status = 1; zone = "zone 3"; "zone_id" = 31; }, { "location_id" = 460; "location_name" = "sheidow park"; "pre_fixied" = "$5.00"; "state_name" = adelaide; status = 1; zone = "zone 3"; "zone_id" = 31; }, { "location_id" = 459; "location_name" = "hallett cove"; "pre_fixied" = "$5.00"; "state_name" = adelaide; status = 1; zone = "zone 3"; "zone_id" = 31; }, { "location_id" = 458; "location_name" = "eden hills"; "pre_fixied" = "$5.00"; "state_name" = adelaide; status = 1; zone = "zone 3"; "zone_id" = 31; }, { "location_id" = 457; "location_name" = glengowrie; "pre_fixied" = "$5.00"; "state_name" = adelaide; status = 1; zone = "zone 3"; "zone_id" = 31; } ); message = "list of location"; status = success; }
its appearing location id descending order want json location name ascending order. have sort location list array separately want whole json , locationlist locationname order
try
locationdescriptor = [[nssortdescriptor alloc] initwithkey:@"location_id" ascending:yes]; sortdescriptors = [nsarray arraywithobject: locationdescriptor]; sortedarray = [myarray sortedarrayusingdescriptors:sortdescriptors];
now change sortedarray other format required.
Comments
Post a Comment