Scala extracting values from arrays and nested arrays - arrays

I have an array: Array[(String, (Array[String], Int))]
I need to extract:
first element
last element; and 3rd and 4th elements elements of the inside array[Strings]
data from 3 records: I want to display only the bolded items
Array((27120,(Array(27120, 2011-12-01 09:59:17.0, 2013-09-07 08:29:37.0, Dale, Hanson, 2578 Ingram Road, Inglewood, CA,
90309),8)),
(92694,(Array(92694, 2013-01-25 04:11:10.0, 2013-12-04 02:31:35.0, Stacy, Allbritton, 4990 Clearview Drive,
Sacramento, CA, 94215),2))
(40581,(Array(40581, 2012-04-03 17:53:32.0, 2013-12-10 22:46:16.0, Norman, Scanlon, 312 Ocala Street, Sacramento, CA,
95761),2))
)
data should look like:
27120 8 Dale Hanson
92694 2 Stacy Allbritton
40581 2 Norman Scanlon
Thanks!

Given your data in in format, Array[(Int, (Array[String], Int))], you will have to map over the array and extract the information you need.
your data structure looks like
Tuple(integer, Tuple(Array, integer)))
| | | |
| | | |
_1 _2 | |
_2._1 _2._2
example,
scala> val data = Array((27120,(Array("27120", "2011-12-01 09:59:17.0", "2013-09-07 08:29:37.0", "Dale, Hanson", "2578 Ingram Road, Inglewood, CA, 90309"),8)),
(92694,(Array("92694", "2013-01-25 04:11:10.0", "2013-12-04 02:31:35.0", "Stacy, Allbritton", "4990 Clearview Drive, Sacramento, CA, 94215"),2)),
(40581,(Array("40581", "2012-04-03 17:53:32.0", "2013-12-10 22:46:16.0", "Norman, Scanlon", "312 Ocala Street, Sacramento, CA, 95761"),2)))
data: Array[(Int, (Array[String], Int))] = Array((27120,(Array(27120, 2011-12-01 09:59:17.0, 2013-09-07 08:29:37.0, Dale, Hanson, 2578 Ingram Road, Inglewood, CA, 90309),8)), (92694,(Array(92694, 2013-01-25 04:11:10.0, 2013-12-04 02:31:35.0, Stacy, Allbritton, 4990 Clearview Drive, Sacramento, CA, 94215),2)), (40581,(Array(40581, 2012-04-03 17:53:32.0, 2013-12-10 22:46:16.0, Norman, Scanlon, 312 Ocala Street, Sacramento, CA, 95761),2)))
scala> data.map(tuple => (tuple._1, tuple._2._2, tuple._2._1(3)))
res20: Array[(Int, Int, String)] = Array((27120,8,Dale, Hanson), (92694,2,Stacy, Allbritton), (40581,2,Norman, Scanlon))

Related

How to select data from array of json object in snowflake

Data I have:
ID
Value
1
[{"code": "SM", "place": "San Mateo, CA, USA"},{"code": "IND", "place": "Indianapolis, IN, USA"}]
What I want it to be transformed as:
ID
Value
1
San Mateo, CA, USA; Indianapolis, IN, USA
This is as far as I can get (table is just a sample)
SELECT
INDEX,
PARSE_JSON(f.THIS),
ARRAY_TO_STRING(PARSE_JSON(f.THIS),';')
FROM TABLE(FLATTEN(input => parse_json('[{"code": "SM","place": "San Mateo, CA, USA"},{"code": "IND","place": "Indianapolis, IN, USA"}]'))) f LIMIT 1;
You're close:
SELECT
seq,
listagg(f.value:place, '; ')
FROM TABLE(FLATTEN(input => parse_json('[{"code": "SM","place": "San Mateo, CA, USA"},{"code": "IND","place": "Indianapolis, IN, USA"}]'))) f
group by seq
-- San Mateo, CA, USA; Indianapolis, IN, USA

Import .csv into MongoDB creating arrays with objects

I am starting to familiarize with MongoDB and now i have to import a relative large .csv file into a Mongo collection. So far I was able to import the .csv file without big problems (either with mongoimport or through Studio 3T). However, I would like to create some arrays for each specific document. Maybe by explaining with an example my data I could make it clearer.
worker_id | gender | birth | employer_id | start | end | type |
---------------------------------------------------------------------------
CAD1213 | M | 1990 | WRF1119 | 15jun2018 | 31dec2018 | 11.1.1 |
CAD1213 | M | 1990 | WAC1134 | 1jan2019 | 31dec2019 | 12.1.1 |
CAF1456 | F | 1972 | WAC1134 | 15aug1988 | 17sep2016 | 55.0.1 |
CAR5567 | F | 1991 | WER9280 | 15jun2018 | 31dec2018 | 1.1.1 |
CAR5578 | F | 1989 | WHI1176 | 15jun2011 | 1nov2011 | 12.2.5 |
CAR5578 | F | 1989 | WHI1176 | 2nov2011 | 31dec2012 | 12.2.5 |
This is just a mere example with few fields (columns). I have data for job contracts where: worker_id is the the identification of the worker, gender the sex, birth refers to the birth year of the worker, employer_id is the identification of each employer, start and end the beginning and the end of each specific work contract, respectively, while type is the specific work contract. The whole database obviously is characterize by more fields.
With the classic .csv import, for each line I would obtain a different document with specific _ids and each column would represent the fields. However, I would like to have as '_id' (although not necessarily) the value of the worker_id. As you can see, some worker_id are repeated in the column (in a file of over 17 millions of row you can imagine how many replica I could have), therefore it would be impossibile to select this field as _id.
Here it comes what I am struggling to obtain. I would like to create an array (for example called contracts) which contains information of each specific contract, hence objects, in this case the columns employer_id, start, end, and type. For some workers we would have just an element in the array (CAF1456 and CAR5567 in the example) while for others more than one (CAD1213 and CAR5578 in the example). Therefore, an hypothetical document would be like the following one:
_id: "CAD1213"
gender: "M"
birth: "1990"
contracts: Array
0: Object
employer_id: "WRF1119"
start: "15jun2018"
end: "31dec2018"
type: "11.1.1"
1: Object
employer_id: "WAC1134"
start: "1jan1988"
end: "31dec2019"
type: "12.1.1"
_id: "CAF1456"
gender: "F"
birth: "1972"
contracts: Array
0: Object
employer_id: "WAC1134"
start: "15aug1988"
end: "17sep2016"
type: "55.0.1"
_id: "CAR5567"
gender: "F"
birth: "1991"
contracts: Array
0: Object
employer_id: "WER9280"
start: "15jun2018"
end: "31dec2018"
type: "1.1.1"
_id: "CAR5578"
gender: "F"
birth: "1989"
contracts: Array
0: Object
employer_id: "WHI1176"
start: "15jun2011"
end: "1nov2011"
type: "12.2.5"
1: Object
employer_id: "WHI1176"
start: "2nov2011"
end: "31dec2012"
type: "12.2.5"
As far as I know this procedure cannot be performed directly with mongoimport, then it has to be performed after importing the whole .csv document (I guess). I hope someone could provide me some hints, suggestions or links where I can find some help in achieving this structure. Moreover, if other structures of the documents could be more suitable for my example, I am eager to know.
Thank you in advance.

Sort by a key, but value has more than one element using Scala

I'm very new to Scala on Spark and wondering how you might create key value pairs, with the key having more than one element. For example, I have this dataset for baby names:
Year, Name, County, Number
2000, JOHN, KINGS, 50
2000, BOB, KINGS, 40
2000, MARY, NASSAU, 60
2001, JOHN, KINGS, 14
2001, JANE, KINGS, 30
2001, BOB, NASSAU, 45
And I want to find the most frequently occurring for each county, regardless of the year. How might I go about doing that?
I did accomplish this using a loop. Refer to below. But I'm wondering if there is shorter way to do this that utilizes Spark and Scala duality. (i.e. can I decrease computation time?)
val names = sc.textFile("names.csv").map(l => l.split(","))
val uniqueCounty = names.map(x => x(2)).distinct.collect
for (i <- 0 to uniqueCounty.length-1) {
val county = uniqueCounty(i).toString;
val eachCounty = names.filter(x => x(2) == county).map(l => (l(1),l(4))).reduceByKey((a,b) => a + b).sortBy(-_._2);
println("County:" + county + eachCounty.first)
}
Here is the solution using RDD. I am assuming you need top occurring name per county.
val data = Array((2000, "JOHN", "KINGS", 50),(2000, "BOB", "KINGS", 40),(2000, "MARY", "NASSAU", 60),(2001, "JOHN", "KINGS", 14),(2001, "JANE", "KINGS", 30),(2001, "BOB", "NASSAU", 45))
val rdd = sc.parallelize(data)
//Reduce the uniq values for county/name as combo key
val uniqNamePerCountyRdd = rdd.map(x => ((x._3,x._2),x._4)).reduceByKey(_+_)
// Group names per county.
val countyNameRdd = uniqNamePerCountyRdd.map(x=>(x._1._1,(x._1._2,x._2))).groupByKey()
// Sort and take the top name alone per county
countyNameRdd.mapValues(x => x.toList.sortBy(_._2).take(1)).collect
Output:
res8: Array[(String, List[(String, Int)])] = Array((KINGS,List((JANE,30))), (NASSAU,List((BOB,45))))
You could use the spark-csv and the Dataframe API. If you are using the new version of Spark (2.0) it is slightly different. Spark 2.0 has a native csv data source based on spark-csv.
Use spark-csv to load your csv file into a Dataframe.
val df = sqlContext.read.format("com.databricks.spark.csv")
.option("header", "true")
.option("inferSchema", "true")
.load(new File(getClass.getResource("/names.csv").getFile).getAbsolutePath)
df.show
Gives output:
+----+----+------+------+
|Year|Name|County|Number|
+----+----+------+------+
|2000|JOHN| KINGS| 50|
|2000| BOB| KINGS| 40|
|2000|MARY|NASSAU| 60|
|2001|JOHN| KINGS| 14|
|2001|JANE| KINGS| 30|
|2001| BOB|NASSAU| 45|
+----+----+------+------+
DataFrames uses a set of operations for structured data manipulation. You could use some basic operations to become your result.
import org.apache.spark.sql.functions._
df.select("County","Number").groupBy("County").agg(max("Number")).show
Gives output:
+------+-----------+
|County|max(Number)|
+------+-----------+
|NASSAU| 60|
| KINGS| 50|
+------+-----------+
Is this what you are trying to achieve?
Notice the import org.apache.spark.sql.functions._ which is needed for the agg() function.
More information about Dataframes API
EDIT
For correct output:
df.registerTempTable("names")
//there is probably a better query for this
sqlContext.sql("SELECT * FROM (SELECT Name, County,count(1) as Occurrence FROM names GROUP BY Name, County ORDER BY " +
"count(1) DESC) n").groupBy("County", "Name").max("Occurrence").limit(2).show
Gives output:
+------+----+---------------+
|County|Name|max(Occurrence)|
+------+----+---------------+
| KINGS|JOHN| 2|
|NASSAU|MARY| 1|
+------+----+---------------+

How can I read List of objects in angularjs

How can I read below result in angularjs in controller.js
{
"placeList":[
[
{
"address":null,
"name":"Len The Plumber"
},
{
"address":null,
"name":"Pete The Plumber"
}
]
]
}
I want to read items in priceList and companyList.
Tried with :
$scope.allresultsfinal = PostFactory.allresults.query({tag: $scope.UserPost.postText}
And
<li ng-repeat="all in allresultsfinal.placeList"> {{ all.name }} </li>
but didn't work and tried different combinations as well but no joy!
Please let me know how can I read JSON structure above?
UPDATE AFTER MAKING ARRAY CHANGES:
{"placeList":[{"address":null,"name":"Len The Plumber","id":"68ce5955681aeac79de1164a75e82163fe6308fc","reference":"CoQBcgAAADoXKm8tL_QZaqqFozoZIjKhA74vbBJt_ZZApl4rwIEheboKkNKX8SaFhQPB3WvospgbMbJZwQO_jzYTVtT_ppC_TPuaSIGectkiF12f3IyizfDs3eEytZFe70w9V9wQB1tiJEkihWYvXJJkyidsbq1kRAGZ4ewmlK2mzeEwIKx0EhD2nELXzgfur0aKgULVj4deGhQU47YfM0t0RjTdWuy2ASuLY9-Gtw","latitude":39.274644,"longitude":-76.629542,"vicinity":null,"website":null,"rating":4.5,"reviews":null,"openNow":null,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CpQBgQAAAIuEtFtu5N2JH2NowGrSdTpUucwbHcetA-oBOzvTsXKoCt07YnoKT9BvihyC6To_eOS3vagwjnUrEBryXA1EQ7sDNvW8CTaR-c6_BOevBOG8kNtzCNLW6YB24shoKhsN4133uP7CUMGiej5riYpF1bTpVuqCvdgeOW5Q9Jygtu6BHAho3cMP7sT5UWqoPWz5ZBIQsI1Q80EUkTp4srSG6XW71BoUmnlcK-yhFb-ebpDZoJQxo5vryCY","height":1360,"width":2048,"htmlAttributions":["Sondra Stegemann"]}],"formattedAddress":"Baltimore, MD, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"Pete The Plumber","id":"9806e0608fd2eb5f6cd32d30d463cdf3cfc0e9a5","reference":"CoQBcgAAAAHw8sDJYXLQZr5f_DtV10UyCd8gCUXbVRcEh6oUS-lvXw-vPuG-w5aj-sU-WJVFrcM3WBlfl3wnNjSlbHPQiA28JV8OJnJsGWOTxT0QR0-9Crh1ItpHOeDNOnWV6_tSCxTzKHBxVMkQUhUMtPWuFtQVf0vKbLF9dit1pzSie45EEhDYwsIfUZtuK7y5-iLj2JzPGhRJ8jSHYb3EyXLjMUadBX2xOB6zIw","latitude":50.951891,"longitude":-113.970987,"vicinity":null,"website":null,"rating":3.9,"reviews":null,"openNow":false,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAXjXZr4uKCAjc_P8vtHMNWjw8DR2ymh0crQ6R94PpAAdM18-hWSHJKBLHDFvjV5XsZXBvCeXKnKEjpI1VeYt_uMhHsigQIx6qZbPWVc8pqCxZWjWMwBGxvP57svNrg8c9uaWXVm7xufhwNcgzS7JEChIQUUeim-4SL-YnGT_lKVjBGxoU7bKtOym0xxLXWSPRtaHh-DbZecQ","height":161,"width":215,"htmlAttributions":null}],"formattedAddress":"4550 112 Ave SE, Calgary, AB, Canada","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["store","plumber","establishment"],"url":null},{"address":null,"name":"Benjamin Franklin Plumbing Twin Cities","id":"b0f38753a78291b8a7cfa3fd363efe3e2a93f63f","reference":"CpQBiQAAAHzXp89UNlCnOYd5L0I2luNj4yblbG19ixChoUmKqKGtJY1mr4NuVCYHOd8RuLjx-h1bqFlBHhxNxXy7ABHYXze0WJcs8Y67yOzs9SNuVbF3nZCHwk49c_3_Ers5a_koQAHLWYPzCAYvA2EnzRJnsJD7dmI5nUPJ6sJ5TXL19q8jhXVSUfppNwgolyQRa1netxIQWXh4naiXpUb_pKSjDLeizxoU1dwd2lp93UNBEtPtdNWOHuL4SxA","latitude":44.99337,"longitude":-93.282932,"vicinity":null,"website":null,"rating":4.3,"reviews":null,"openNow":null,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAp3VD7Y2wdvi0tqusfypYvqpg-NYwVLV-VGdo9ZP9gpzPk9JORNR_3J0An6IuEXurAWL87KTr0o2q4fOr8wB9ZhfcncBmaEONlPVY43Kl0RHhQ9ctPtFLlVeSS8vqefKmx1ldiJvU9Doa-SooBPXBRxIQee2a8aKYbwLb4NzbgjIFsBoUUHcF48_4vIQEaOK0cCkVzvczzwQ","height":864,"width":996,"htmlAttributions":null}],"formattedAddress":"1424 N 3rd St, Minneapolis, MN, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["store","plumber","establishment"],"url":null},{"address":null,"name":"Spartan Plumbing, Heating and Air Conditioning","id":"80eecdbfb66ff75c1b461d0ca6690fe15c7618c3","reference":"CpQBkAAAACqxzWLYjUZYHHPPj51Pc_84Bw1IVwGNhGxyb3PKuz8a52cPQDYsGUdTg5o6jsrtGTSsPo9WSp1axn-XSN9Cr93XdQYq7gLqarO64FHAARUvKxtyHBIRVSBl03L5Kn3cbFMjV7WNJjkxHqhsW41poE9WWrNAuK6rYNFplgCz1wJGuGxu2NoisWYg6jRgd7NclBIQegU2fVgp-luhPNlP82gB8hoUEw2sU-Jkjo_TFeTAG3Q6TERcqS0","latitude":38.908787,"longitude":-77.027239,"vicinity":null,"website":null,"rating":4.6,"reviews":null,"openNow":false,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CqQBngAAAOtwwljV6BUyMzQEEnFXrO653KlML9vNeJ1eYR5Unwb3CoWKFF7T4ADkMOh5hf8D-kPSkayxxv5I-nwGW7nlXJ6mOazfexL-YMME_-AIZfhqkpavqPOXqlayZt2mMjEH-8cwy7Q1Xztm0v9Gy1PK7aM49wXlqcXpM8fzL5WKHxynB5qapJza_PLAckacGFonJd_O_Y0NKZX-EGbB2rzj9twSEAWf9WNXagEecQ4zA5FXQYEaFBv-WW37J-UW_2xeN3kVxj04gO2f","height":200,"width":300,"htmlAttributions":null}],"formattedAddress":"1776 I Street, NW #900, Washington, DC, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"Bell Plumbing & Heating Company","id":"39015ba7fa6e5dffb12948bf15254b279291b01d","reference":"CpQBggAAANen7uzm5gqVr0ABvT5kQDf8IYl6VJ6j9E1SAyK2f2ehbVFeO6Kb9fOoNUGmnxsYMzEBCE4RyV1EZHhm8hEjcmtFKg7EreM2JCYKYVfesu2oBVQWxV2fM93qKxVJnVcHM5Tuz1U--sbQSkvIlI6oJ68d_FQcnrNJK_uu9ZpXUs505wuiBsK2xuX12H_zsZ2_SxIQg2-UoXqV-qYXMkkkqaEY9RoU_cDNteVqty1_l1jmRf0tuV_AsME","latitude":39.677725,"longitude":-104.826517,"vicinity":null,"website":null,"rating":4.2,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAtXaWasdyoExEkFoE-98psIdsD5_2Vc52G2NS-Mth12OUiSabCap79aaiHsVCqDi3GzOXAzt64Ic6laDKbEwxXNb8xekJi0R3PAUK870HxYwwAaW_rTiusw27e0BP-Xo26uwth98Yo5hj5STdK9t2ihIQPzuvbHVQJyjVVmMOGkp6XhoUaawKUL3LXFSppEOh5ZTzVpmLG4M","height":403,"width":604,"htmlAttributions":null}],"formattedAddress":"2150 S Abilene St, Aurora, CO, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png","types":["general_contractor","plumber","home_goods_store","store","establishment"],"url":null},{"address":null,"name":"Abacus Plumbing & Air Conditioning","id":"5f5178b50c72b6810470b1345f7fd190dc52f479","reference":"CpQBhQAAAJz5wpqUQYx6M8K4921h3X3licmU2-NT7hbAs5bc4IbcekchOuNvm6Lax_nzhmIz9hpMk6OKU4PW6QfnO7OoBCPJFhIwi3IJYsPqUdtWcu1exgnq9yHLlXv6jUwOOEDfN3N644SaDMKSUO_VtXI-uHPe4s2iwCxtQh_ymsRnu_dGSAk1eSbpVx7f7-HH_dYYZRIQuAFxej0C5LnZKeFoiLLXBxoUKZyl2yBvNzcfSPIdaFiJ2eIUkW8","latitude":29.949188,"longitude":-95.315495,"vicinity":null,"website":null,"rating":4.8,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CoQBfwAAAGaknJnYxszrLa5gp6GGNTgz7lZBx2vrL-oWtO-x9QuldQeaEFZrU0U4-9kTKeqG-LcIlfUiJ6IX_5PpJ_-nraAu6wnCdTi7-ZJ5qVvhX4hnCv6573n_HVBEE0qRyzWhx3LsAloTJ9PYZS3-zO27DeLUSUgyOMM6k2OSYSwx3CP3EhAbqFmyv1bbTvkZlnX9KXiOGhTLUF-sxw5U13OYFGvDigrogQOrsA","height":1557,"width":2048,"htmlAttributions":["Alan O'Neill"]}],"formattedAddress":"15851 Vickery Dr, Houston, TX, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png","types":["general_contractor","plumber","home_goods_store","store","establishment"],"url":null},{"address":null,"name":"Aramendia Plumbing Heating & Air","id":"72ad80f537f0fbf23e447aec7d8c6a9ea238c3d5","reference":"CpQBggAAAGAxQWta7ZYHWWMdmoJe4rLoOIkyCyzCyVYuYhd_LhZsgCebsFK61DLtKlPG7b91lB4IvWeB_50fUuZaPlrdQinqQlIBmbGKaoMf15Cv2YX3ODArzSgb8F2lV689phC2j97AaY5KbxytPMFT0Im2rh5Tx9m4hUoY9Yc7YuFiGdbLKEWEzHpnr35Os1LM1VsefhIQ1KKT1tWUlMQJijtXY5eM6BoU1lZJ6zC21OlX_f_KoLYN2V9h-94","latitude":29.541232,"longitude":-98.381041,"vicinity":null,"website":null,"rating":3.6,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAwDqG0L-E9PQEZjNmwVSjOFUrfeaZtmuEG3DYQSUwK5HZjfcVK0nlY_lAfot7_SvLxwrgT7G2F1DrdHPdfl5MscfVeREZn9s2NokzSsSUT982W51mR8KuMcNmL035k2_XiltzvE-hkBF-9YCrvsv7LBIQa_qyfX3OZuHavnkJF9Ms-RoUXNHTopx9-Lzfnho1GfCDBvSbpdo","height":282,"width":425,"htmlAttributions":null}],"formattedAddress":"5511 Brewster St, San Antonio, TX, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"A. J. Michaels","id":"6ad1e733e64274f6878ac9154429c96b73def7fd","reference":"CoQBcQAAAJCu1Z2XfhmwkmfdrsxeUSuD35wlKB5CvGxE6EwYrY5S2CMX6TRdqSXaV-hVoBheX8-He_UCI2t60mP3oY3cp3VLL0WCvNA7KyRYyw4O1aBkXNhUWpvuJWokyTpZRqB25edGBMUy_GyR5cub8spQVex-424zMPWm38tGfFXuozmvEhAoKvUoE3E3VrdJomKvdDAEGhT9pLxKlI7wPGw2pPKJdsIom93QAw","latitude":39.344039,"longitude":-76.609781,"vicinity":null,"website":null,"rating":3.3,"reviews":null,"openNow":false,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CoQBcwAAADI8pSUhg-sjDvHOS4ODulwTq3RSnNjchZoX8S88ty39pqIjYyv85k9jVvIev4h-Og7a9RUzUl2cf9DHIvfmV7mdchZ0OipDuuE9b-1XbGjAVa2H0sdGLouVmWV2GbFaOoB2S60jPgSYOsG9T5eD5Ps3K9whd4KyhM8EY46GZg5KEhC8xm34eFiHvfU006H0kAmXGhRadZDEBBe3CEBcvYgN-W47bgKtqw","height":225,"width":300,"htmlAttributions":null}],"formattedAddress":"4512 York Rd, Baltimore, MD, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png","types":["general_contractor","plumber","home_goods_store","store","establishment"],"url":null},{"address":null,"name":"Holt Plumbing Co., LLC","id":"e7b1cfd226a598fbdf85c0c0d3ab0a33bf9112f6","reference":"CoQBeQAAABQwpgLT09s4cnzqRN1i0msC3Ix5qmv4Rzqmoms-g_y2kfR2X86NxcJDKvRlDMJ2V-64KZSywZU0VuXndO2XRFwSyWLTvgFnn95lLtnr_0tSaUEYiMVkAlHmEQIrmtLAcNdH8YiTpqp_NzJeh08kBLlyhUoxsyyUuqRiGTht0M-tEhBl8EH2A7pgDNNR5CQSA6FoGhTa0-PcMfUPwynfLM9rxZ67nzZNAw","latitude":36.151228,"longitude":-86.673433,"vicinity":null,"website":null,"rating":4.2,"reviews":null,"openNow":null,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAxI4ZkwS7uls2G84fQJfS41UYFvdoFwFt_I0yc5Xgdan4u1elvNATHU6ayJ_LVyNOeE5TLaOKn83UbLSse0gRpGCyMSCb8ei2M0BShty7O2SHGPMgPGXTT0FVhy2GDZ5DErOpfQKZclsiuQHat4wdNxIQQDun971FMDcppfbopFcXjxoUmUujUMNcdiT7tN7xuftPdLGzzrk","height":128,"width":175,"htmlAttributions":null}],"formattedAddress":"Nashville, TN, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"C Anderson & Sons","id":"1679b35fc8b92ad2cb19bcccd62f86e3c41ef2e6","reference":"CoQBdAAAANV2v237Ohe82V11i9XSpb5LXPPl7Whp4aRo073veTJuCvr9Ag4cu1qhbjvlHBDAqaIpJBvLXjwoQVSYYiipx9N19UktfySh1LBNIB_u7ITaf8Yzsj0OPpoPNDMdWGryoQRnS14FbOWcTgOj9-UCe0lSHaSCO_YUjL0vtzmwwP_OEhAUfJiEtHvd7e5xeGgnD6AJGhSeZ__OaI9QgUfbl7_sV5ZpMv1gbw","latitude":51.479721,"longitude":-0.207459,"vicinity":null,"website":null,"rating":4.0,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAkim1GQCuxeZ1BBX14UD_Z4HFKlLyC2pOaVePehH1njoCytH32u0OG6ceS-whEaiCrnTO1hv0BdGZ9if0-Zp2JFYUqKYMBE8yHHgzyXHBsk_AvkEn2e70myGxKufBXcdxg5brCaancxBcUwXZ_k7RBhIQCXb7R3hNbU_dNVVwXV2AxRoUdh_UqDsi0WVO-XB702lkzkf4FEk","height":335,"width":530,"htmlAttributions":null}],"formattedAddress":"25-27 Filmer Rd, London, United Kingdom","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png","types":["general_contractor","plumber","home_goods_store","store","establishment"],"url":null},{"address":null,"name":"Pimlico Plumbers","id":"8062fe5810ffaa733ce504072ca3295966332e94","reference":"CoQBcgAAAO2MC7ALolmHyt7MtQErt4G7xihkJmDvf8ib096xs1l_pnSzhHqqyrzgWLaA11ZZbxulUQnhgw7KOmBWcmgXG12O_e0ig0ZSrI4CySlg6CHq9p2bioaJ3YKhvcySDvmOu5m0Np8Nsk8MLJf1YTWjZyMRuDSxvNOVYUICj9JxDTuAEhA3g1-TDSXCNw-0sLG9ABdMGhTOF3rmkZ5tZi3dPhjKXt4yAw9VFA","latitude":51.494874,"longitude":-0.115856,"vicinity":null,"website":null,"rating":3.5,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAA50_GnNSc9llmBg5SREcAVcO-UR0oWuoQi8LV0sJV7RJtDnvSm-CPLZktlTl_20ba1jKYZToFGra8gmgKb3HwAcLcl0eGawuQHdnyd6LRNvNJQxkBFcxRYgsbNwvZYjwDGJqF3qvIvnJ1qEm-6K5slhIQPFq3cWKPltXHjkgvHFsw8xoUlCMylqYTW3fwjIn6tUKD3vUOuPY","height":620,"width":938,"htmlAttributions":null}],"formattedAddress":"Pimlico House, 1 Sail St, London, United Kingdom","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["roofing_contractor","electrician","locksmith","plumber","establishment"],"url":null},{"address":null,"name":"Benjamin Franklin Plumbing","id":"f8d721226559cecbb165265bb1974d0c1d5ec1b7","reference":"CoQBfQAAAFCKKEX7rrdSRr02tLr7yy4YXL_nuTidKURZWbs-awNfqBmumEPmxv3657u3Nb2KpFBftHvhxrSHHcRKvatppz1aGOoSMot-9pXole7UDeyZCtEMeZPj4O46nnqhSsced9SuJeXL76Xe9ogbBX933Wa_hNBC-oCuITjPJPODMIfIEhAo4sJyKxJQeVFFVAjVh94ZGhSyDRgxeUrZub6cbSqsFlvwkXnk0Q","latitude":39.74872,"longitude":-86.02525,"vicinity":null,"website":null,"rating":1.7,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAASDc2PB7kuLjpZJtSHC8AHh1bEVTXGnXmcJLZzyHZxElCZ4o8HLRAvEw1Fz4uLoK016k7Bv7MUiO7m7t51yAJwSMICYeAydWxFu-ivS-0pw4_fWKPakvy3UZZTUpZ73CEPC20hgY2s_c-BCKeEQPWZxIQ68K1H4llAA8Wn9_wsVf7XBoUZsuddPrODTPxpfGsOfalWjdXPx0","height":500,"width":500,"htmlAttributions":null}],"formattedAddress":"Indianapolis, IN, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"Terry's Plumbing, Inc.","id":"fa8f6ce8e8f741246eaa653b31cc22fa4c29f880","reference":"CoQBeAAAALRsQpj9FovJW6bO5-JYuJSeVl6qcPxVZMe8sx4h3_zxsYIuWmeGWTD_flIp2HSoUivip2acISgvmbwjca388ZfEN5I41dmUTIBLAaElpPOTdg2PR9msbgXGRwXbWMWHAjvmxC31xHngyxQtJ3ZCKzl5UX2gjaGIrvBEKYGhryEvEhCKAMNaJJ0j3gpAzlvhYbfmGhRY6NiMajXJ1DiakLZU6jbIpO53xQ","latitude":40.52509,"longitude":-80.017018,"vicinity":null,"website":null,"rating":4.7,"reviews":null,"openNow":false,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAs-rwRpyC020biDPdK_gc7k2sai2VEYY6u4rCPtpuggEOIjYv8HiRRfkVj2BRxGPa34qsfTsE-6uOUd4RkdBcl_o6UG9SxJTo7R67N_fju4nJ6uUkeapS3BUW8HfMafy9y-csMq7WsnCxyfrUGAez0xIQMAZM5z2Sm3TZU96Y_BHcOBoUGR5wzG0TWufmGLNL8r0BId6EO90","height":682,"width":1024,"htmlAttributions":null}],"formattedAddress":"3227 Babcock Blvd, Pittsburgh, PA, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png","types":["general_contractor","plumber","home_goods_store","store","establishment"],"url":null},{"address":null,"name":"Apex Plumbing","id":"3c9b9735bf70d1dd20d3b89cb88478ea50c6d096","reference":"CnRwAAAAtzguF7DRlDjHq68rcisgpMlgZyYKvsRkQu3Fvye5R7BDdTbWiLkN4DZQsM-oJ8sZVZXoBN-bMByDaQDXFVrI7fIjEd_rWyYRfh6e1sqTHA4zC6KMLYpWYIPgYLyADLu_tskitOIkxcpFync8CeGl2hIQGzgbxRaVKTv67Bw4zPkJXhoUMhmLD7Shhl4i-cMyTN5exS6rZbw","latitude":41.953804,"longitude":-87.706418,"vicinity":null,"website":null,"rating":4.9,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CoQBeQAAAC5AozV_qBUw31nsD8ZpZsSgSN3rXGqlketah6_WErPsgUIEfqXZuZ1NX5ayAkXWtsIUaykj2H4JDyYFx9iG_iZg-aA9YQCjECN7TEyKa5Whck8rF9YGFIYYX8FWQ4G53RB8A90EwcVQa3x5tT35jK9oLsEXd-3n3J2LPh64P4A6EhBVaodRhvvEf8M2fTvU7UB_GhSE8Ae4XKKWDrQZ7ssliriYwPL1OA","height":1152,"width":2048,"htmlAttributions":["Charles Osleber"]}],"formattedAddress":"3119 Irving Park Rd, Chicago, IL, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["general_contractor","plumber","establishment"],"url":null},{"address":null,"name":"Fox Plumbing & Heating","id":"150d6443bdaeb8dc1841adff63be5637a34b8de5","reference":"CoQBeAAAAC0GQq3UqC2bx0NTSmtxBkN-lv11oI4kiB83z0cKsktfAZgFXZAg6VV8AsME-lqZnrBbIDfZfyLeC9fqmk3uufbESnQyrAz_oNZBJ2OGfWM27-meGMInxq9XaAoNU6GOPAnNTDNnD2Ll5xqjhysa0iWKm7TASX64NEz0vggLMra8EhDFsMBf12DZ53A1HRySg5WxGhSt0jlq5Nk3BKCoN2hWpxG4Tt0xmA","latitude":47.535489,"longitude":-122.331765,"vicinity":null,"website":null,"rating":4.8,"reviews":null,"openNow":false,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAYcdmghDjvsqxEQz9fQPnxb4XqKcR2RH4w2AuUDrhvsZDc18tki2a0njttAwPXbLRhipXayn8YuCQjI7ACRIQ_l19Jg6xWIR73JKYxHJrXF7BjgUlW2HmD0CT5rfI3o9mCJAylNA8Rk9f2ufJ5fobORIQF9YDjvFFX44uK69Fj45xGRoUXTDYKICnBGEkQsGe5PBVKxwH9xI","height":381,"width":577,"htmlAttributions":null}],"formattedAddress":"7501 2nd Ave S, Seattle, WA, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png","types":["general_contractor","plumber","home_goods_store","store","establishment"],"url":null},{"address":null,"name":"Rainforest Plumbing & Air","id":"d58d852122e39d33a4fe588561877a9af01bdb18","reference":"CoQBfAAAADpKlNVqXHp53kR-TPJDJyd-VElcNy7L5ejbb3w6mNDQPJzd001Qha7SkwImvug3p8NzJq82-NdWqPQQQU3PFdRV05rwgQY0TwQJeP4bbVMvVnsz1mtfUh4kgfsgPRnwteJw4XwesKiSSWOBVJl3WpF9KZCn216XY3fsL7a4rl1_EhDKevqnmUrd9AOEWkw7ov4KGhRy1KR1prrcw2aAhBzO7TgHBmzctg","latitude":33.300857,"longitude":-111.970018,"vicinity":null,"website":null,"rating":4.9,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CpQBhAAAAGJTyRvZNFFT8ufGGryB3td_ef0ize2PggajQ9bK732jWR_hMSrDn3fXdolwRfZSu8bdG3w6fyhbkN9lQYx4rHuDzsod31V0woZwyxac8h-pOZ86Xmul7T2um1CEDQparhECW7Dt25JImvyTnYqerE4Mf8yIYwofbrR_Rl4nNku3mTZU99IpZLnptEdqX5WtkRIQYejG5p14A-KJSt2mToosmxoUhmQot-q8iTJQKJ2cJoml6HWkBsA","height":1200,"width":1800,"htmlAttributions":null}],"formattedAddress":"127 S Weber Dr, Chandler, AZ, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"Milani Plumbing, Drainage and Heating","id":"fb154a0e342135f1b0d0882e96041696e3779edd","reference":"CpQBhwAAABIn5uTwVt2_RP1tWnbdfdHh8_NQo2dtouGhVvlpKepRnxDPHAbwiLX-2mlCFlpOTQMgKYdTVnXukEIA-VdU4RWU6UMT7TbJOQldmzepMoF9KX7MeB4teH64y5XaczPfKrpkPRwQpDsz-GGyy8GiIo0bX2mZvFvLrlQlIIrknRCsE87_3_z5LCOm8ScdGSrSrxIQbVeoTtNFiz8mZ9PcVwDu2hoUKGn76xEjtdc8DNj73LiFogdd7Us","latitude":49.223408,"longitude":-122.984293,"vicinity":null,"website":null,"rating":4.5,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CqQBkwAAAMmjVpIbWQBaKZw3psL_97TihUDxbBxW-WqNicf5XiXTZWh-FB8SOV6E7ATSDBW2leUfTUYRirUeqOZ_Qd4xfvH6bHpdWdjhUee1jZixORC12tkYnUb0y7u9zZnIVplWa_Xeekc5L5GhtopAqXPgaqxjmjqqqVctUkz-hLsBlwtOCDVm7GsTNJsHxpqVJ-jhxrsH-jztwG1JnO5bZyQlVmwSEAkw5RQrAZFwIpohI0y547saFHImQF035VNSA5Y6h69SJpYVnpKs","height":225,"width":263,"htmlAttributions":null}],"formattedAddress":"5526 Kingsway, Burnaby, BC, Canada","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"The Plumber","id":"f724b7a587b5910dcf86b7eb955feff999c803c8","reference":"CnRtAAAAyc5Z9bK1CWBI0RSU_T7rGOoyOLGubuK9TnlKiC-ymjbsfe1UWbaq9dMlVIBJGJhIOisPlpVHhKOaBeSwfHGaieyc0ViKFwL5zJy_QLOAMlVn-IEEctKcZHniJnqO7VEdTE_mWu65gtcXOWfrtrfhzxIQyRIZgPSbg_J4OnDNDZQzYBoU9LBbWcRX8zEIIiJ-ktnuLs2T93c","latitude":32.90083,"longitude":-97.114913,"vicinity":null,"website":null,"rating":4.9,"reviews":null,"openNow":true,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRuAAAAcPGh9z8mZ1QU7JD_bn5LOgHSfUqrQMVKt-Oy1VHctFV4Hfs02cZ1s5KrGeKrBpkAyJOitz-uviEXfRRWVf7X2JZPy1Qa0_Buusgdbl9IeQRXz-lPePMxfyTNkRJLochK8W_ZSggKfCfDIUWp9HUHQxIQTc5ogsim3Ov8p6L_VO60fRoUEWsAeMJuA4uspVz6nUNK-HTsMh0","height":281,"width":284,"htmlAttributions":null}],"formattedAddress":"3407 Lookout Ct, Grapevine, TX, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"Plumber Inc","id":"0f55100d5bdf98af96cd76d86629a90ded8c9e89","reference":"CnRuAAAASj8u0xxro9jy_Z4OGOfZ3FSNaqhR2qrfW7PQabBDWizhQks49dn1x2QUCygwuG38-0uOgH2EzTzWzx8WafoaZhrcytPnopAk2stsqV3JclcVbrEiUBQ_61TOR9vKT7qbSyq2jgJVnk3NfYsmIFUPTRIQMS0cLuRxGb0iJkVaYt9BhhoU6HzBITIHXp0Mpfetokb7xwGLeA4","latitude":41.432029,"longitude":-87.354171,"vicinity":null,"website":null,"rating":-1.0,"reviews":null,"openNow":null,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CnRnAAAAyZbeFQtJmSL4bMOZ3A7MItx5BK5l56uF_OXlnNDuQ1aF9Owk3wF5eJa2sufkWHmMyKHTPP7Yea9kXOa4GE61J_MmMb5wvKDml2WLOv0Hk4eeLFzrwJImesTj_x6tx2YmMQ-bta7UZQ2JXytUKVcFMhIQa5wNWM-cRPYrKAbqv8s4EBoU6xodmCOsmVQNRXDBraTpYGfGbG4","height":300,"width":525,"htmlAttributions":null}],"formattedAddress":"1280 N Indiana Ave, Crown Point, IN, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","types":["plumber","establishment"],"url":null},{"address":null,"name":"Dallas Plumbing Company","id":"000cd8825cb9f0f5e5e77a635a4179799137351c","reference":"CoQBegAAAOzZdOtTzElz1lMFi-8_yZqeImqaOF-5Z8GWHqa65OAH8insCBSoY-VUJOiOKsTZtDxi_XoZRE-mE5F-lC7lyS-mZXQ5oCfa95YyhzQHqxcdvyJ7jLSR_1eEg3sTWIuVpqZT-qArhxkR6SToIGl3iVoS-n0EmEV9tq1S0hqwAwuXEhBAYlvq9ubBRMMxtX8xim4tGhSs_xlPOhEuI050-I7ASHrmhqBJ2w","latitude":32.899274,"longitude":-96.701046,"vicinity":null,"website":null,"rating":3.0,"reviews":null,"openNow":false,"events":null,"utcOffset":-2147483648,"photos":[{"reference":"CqQBlgAAAKuYNIDjmeJV3k5qKk815jtdw4f4MJFO9rAoj61elDr5mkmuxpQUeVDbwA0LQTKDaHANTAkXHndsIkMaVXrBO-t7ZSvS7SMSdhWZobeZx2VILGfdwxRTAup_AbqUbOLeEG-Pn6owdppXT0tOGmpyoZKSn8dnYGHqf-XIonfcvzRSD9vlU3ZMjbU1xFYh48wWM-jfTyhTaFPu10FFWJXcqmkSEOYVxoJieb8VbjOxfg6Ze4saFKLIqYTAtguX0ueYX5BX-DosZejj","height":186,"width":288,"htmlAttributions":null}],"formattedAddress":"11055 Plano Rd, Dallas, TX, United States","intlPhoneNumber":null,"formattedPhoneNumber":null,"priceLevel":-1,"ratingCount":-1,"openingHours":null,"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png","types":["general_contractor","plumber","home_goods_store","store","establishment"],"url":null}],"companyList":[{"id":1,"companyName":"ABC Inc","companyDesc":"Household Company","companyAdd":"a","companyEmail":"a","alternateEmail":"a","phoneNumber":34234234,"altNumber":423423,"businessKeywords":"launfry, plumber, electrical, cleaning","ownerName":"324234"}]}
Your placeList is array of arrays of objects. According to your <li ng-repeat... JSON should be following:
"placeList":[
{
"address":null,
"name":"Len The Plumber"
},
{
"address":null,
"name":"Pete The Plumber"
}
]
Alternatively you can update ng-repeat to output that format:
<ul ng-repeat="place in allresultsfinal.placeList">
<li ng-repeat="all in place">{{ all.name }}<li>
</ul>

Sorting a PHP associative array

I would like my associative array to have its elements sorted. Currently, my array is like:
Array
(
[1585] => Chicago, Ohio,Dallas, Denver, Detroit, Houston, Las Vegas, So. Calf.
[1586] => Chicago, Ohio, Dallas, Denver, Houston, Las Vegas, So. Calf.
[1588] => The Bay Area, Chicago, Dallas, Detroit, Houston, Las Vegas, Minneapolis
[1589] => Charlotte, Chicago, Ohio, D.C.
[1590] => Orange County, Orlando, Philadelphia, Phoenix, Richmond, San Diego, The Bay Area, Seattle
)
Whereas I would like this array to be in ascending order like this:
Array
(
[1585] => Chicago, Dallas, Denver, Detroit,Houston, Las Vegas, Ohio, So. Calf.
[1586] => Chicago, Dallas, Denver, Houston, Las Vegas,, Ohio, So. Calf.
[1588] => Chicago, Dallas, Detroit, Houston, Las Vegas, Minneapolis, The Bay Area
[1589] => Charlotte, Chicago, D.C., Ohio
[1590] => Orange County, Orlando,Philadelphia, Phoenix, Richmond,San Diego, Seattle, The Bay Area
)
Thanks ....
You need to loop over each element explode on the , to get a list you can actually sort. then you can use a sort function on the list and implode back to , separation. For example:
foreach($arr as $id => $list){
$listArr = explode(',', $list);
sort($listArr);
$arr[$id] = implode(', ', $listArr);
}
This is just a simple example. Depending on the format and consistency of the separation of items in the string you may have to add in some trimming or use preg_split instead of explode but that should give you the basic idea.

Resources