对JSON格式的城市按照拼音首字母排序
需求说明:
- App应用中最常见的一种操作就是对城市按照拼音首字母排序,以方便选择城市。而已有的json格式的城市数据是没有这种排序的。
已有的json格式的城市数据格式如下【简化之后】:
数据格式说明:每个城市(省、自治区、直辖市、普通市、国外)都包含3部分,即当前城市的code、父级code和城市名称。
- {
- "city": [
- [
- "489",
- "0",
- "全国"
- ],
- [
- "530",
- "489",
- "北京"
- ],
- [
- "538",
- "489",
- "上海"
- ],
- [
- "548",
- "489",
- "广东"
- ],
- [
- "763",
- "548",
- "广州"
- ],
- [
- "539",
- "489",
- "江苏"
- ],
- [
- "635",
- "539",
- "南京"
- ],
- [
- "561",
- "489",
- "香港"
- ],
- [
- "562",
- "489",
- "澳门"
- ],
- [
- "563",
- "489",
- "台湾省"
- ],
- [
- "480",
- "0",
- "国外"
- ],
- [
- "481",
- "0",
- "阿根廷"
- ],
- [
- "482",
- "0",
- "澳大利亚"
- ],
- [
- "527",
- "0",
- "英国"
- ],
- [
- "528",
- "0",
- "美国"
- ],
- [
- "512",
- "0",
- "其他"
- ]
- ]
- }
需要将上面的格式转成下面的格式:
- {
- "a": [
- [
- "562",
- "489",
- "澳门"
- ]
- ],
- "b": [
- [
- "530",
- "489",
- "北京"
- ]
- ],
- "c": [],
- "d": [],
- "e": [],
- "f": [],
- "g": [
- [
- "763",
- "548",
- "广州"
- ]
- ],
- "h": [],
- "i": [],
- "j": [],
- "k": [],
- "l": [],
- "m": [],
- "n": [
- [
- "635",
- "539",
- "南京"
- ]
- ],
- "o": [],
- "p": [],
- "q": [],
- "r": [],
- "s": [
- [
- "538",
- "489",
- "上海"
- ]
- ],
- "t": [],
- "u": [],
- "v": [],
- "w": [],
- "x": [
- [
- "561",
- "489",
- "香港"
- ]
- ],
- "y": [],
- "z": []
- }
实现思路:先在城市中增加一个拼音首字母元素,然后根据这个首字母对城市排序,最后在移除这个首字母元素。
- [
- [
- "489",
- "0",
- "全国",
- "q"
- ],
- [
- "530",
- "489",
- "北京",
- "b"
- ],
- [
- "538",
- "489",
- "上海",
- "s"
- ],
- [
- "548",
- "489",
- "广东",
- "g"
- ],
- [
- "763",
- "548",
- "广州",
- "g"
- ],
- [
- "539",
- "489",
- "江苏",
- "j"
- ],
- [
- "635",
- "539",
- "南京",
- "n"
- ],
- [
- "561",
- "489",
- "香港",
- "x"
- ],
- [
- "562",
- "489",
- "澳门",
- "a"
- ],
- [
- "563",
- "489",
- "台湾省",
- "t"
- ],
- [
- "480",
- "0",
- "国外",
- "g"
- ],
- [
- "481",
- "0",
- "阿根廷",
- "a"
- ],
- [
- "482",
- "0",
- "澳大利亚",
- "a"
- ],
- [
- "527",
- "0",
- "英国",
- "y"
- ],
- [
- "528",
- "0",
- "美国",
- "m"
- ],
- [
- "512",
- "0",
- "其他",
- "q"
- ]
- ]
代码实现:
- import basedata.MunicipalityEnum;
- import com.alibaba.fastjson.JSON;
- import com.zhaopin.core.utils.CommonUtil;
- import com.zhaopin.core.utils.PinYinUtil;
- import java.util.*;
- /**
- * 基础数据中的城市按照拼音首字母分组并排序
- * Created by SYJ on 2017/10/19.
- */
- public class BaseDateSortAndGroupTest {
- public static void main(String[] args) {
- test();
- }
- public static void test() {
- String cityJsonStr = CityJsonStr.cityJsonStr;
- City city = JSON.parseObject(cityJsonStr, City.class);
- List<List<String>> oldCityArr = city.getCity();
- //根据拼音首字母排序
- List<List<String>> cityList = sortByPinYinHeadChar(oldCityArr);
- System.out.println(JSON.toJSONString(cityList));
- //按首字母分组
- Map<String, List<List<String>>> map = groupByPinYinHeadChar(cityList);
- //输出最终结果
- System.out.println(JSON.toJSONString(map));
- }
- /**
- * 按首字母分组
- * @param cityList 例如: [["530","489","北京","b"],["856","556","宝鸡","b"]]
- * @return
- */
- public static Map<String, List<List<String>>> groupByPinYinHeadChar(List<List<String>> cityList) {
- Map<String, List<List<String>>> map = new HashMap<>();
- List<List<String>> groupList = new ArrayList<>();
- //遍历26个英文字母
- for(Character i = (int)'a'; i < 'a' + 26; i++){
- Character c = i;
- for (Iterator it = cityList.iterator(); it.hasNext();) {
- List<String> city = (List<String>) it.next();
- //避免city.remove(3)之后再city.get(3)导致索引越界
- if (city.size() < 4)continue;
- String code = city.get(0);//城市code
- String parentCode = city.get(1);//父级code
- String headChar = city.get(3);//首字母
- //过滤掉省(直辖市和港澳除外)和外国
- if (CommonUtil.isNullOrEmpty(headChar)
- || "0".equals(parentCode)
- || ("489".equals(parentCode)
- && !MunicipalityEnum.isContain(Integer.parseInt(code)))) continue;
- //比较首字母和当前取到的英文字母,不匹配就跳过(注意c.toString()不能少)
- if (!c.toString().equals(headChar)) continue;
- city.remove(3);//移除最后一个元素(首字母)
- groupList.add(city);
- }
- map.put(c.toString(), groupList);
- groupList = new ArrayList<>();
- }
- return map;
- }
- /**
- * 按首字母排序
- * @param oldCityList
- * @return
- */
- public static List<List<String>> sortByPinYinHeadChar(List<List<String>> oldCityList) {
- List<List<String>> newArrayList = new ArrayList<>();
- for (List<String> arrList : oldCityList) {
- String code = arrList.get(0);
- String parentCode = arrList.get(1);
- String cityName = arrList.get(2);
- //取每个字的首字母
- String pinYinHeadChar = PinYinUtil.getPinYinHeadChar(cityName);
- //只取第一个字的首字母
- pinYinHeadChar = pinYinHeadChar.split("")[0];
- List<String> cityArrList = new ArrayList<>();
- cityArrList.add(code);
- cityArrList.add(parentCode);
- cityArrList.add(cityName);
- cityArrList.add(pinYinHeadChar);
- newArrayList.add(cityArrList);
- }
- return newArrayList;
- }
- }
- import java.util.List;
- /**
- * 城市
- * Created by SYJ on 2017/10/19.
- */
- public class City {
- private List<List<String>> city;
- public List<List<String>> getCity() {
- return city;
- }
- public void setCity(List<List<String>> city) {
- this.city = city;
- }
- }
- /**
- * 直辖市、特区枚举
- * Created by SYJ on 2017/10/19.
- */
- public enum MunicipalityEnum {
- BeiJing(530, "北京"),
- ShangHai(538, "上海"),
- TianJin(531, "天津"),
- ChongQing(551, "重庆"),
- HongKong(561, "香港"),
- Aomen(562, "澳门");
- private int code;
- private String name;
- MunicipalityEnum(int code, String name) {
- this.code = code;
- this.name = name;
- }
- /**
- * 是否包含某个城市code
- * @param code
- * @return
- */
- public static boolean isContain(int code) {
- MunicipalityEnum[] values = MunicipalityEnum.values();
- for (MunicipalityEnum e : values) {
- if (code == e.getCode())
- return true;
- }
- return false;
- }
- public int getCode() {
- return code;
- }
- public String getName() {
- return name;
- }
- }
代码中用到了阿里巴巴的fastjson,所以需要引入相应的依赖包:
maven依赖:
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- <version>1.2.4</version>
- </dependency>
Gradle依赖:
- compile group: 'com.alibaba', name: 'fastjson', version: '1.2.4'
完整的JSON格式城市数据:
- package basedata;
- /**
- * Created by SYJ on 2017/10/20.
- */
- public interface CityJsonStr {
- String cityJsonStr = "{\"city\":[[\"489\",\"0\",\"全国\"],[\"530\",\"489\",\"北京\"],[\"538\",\"489\",\"上海\"],[\"548\",\"489\",\"广东\"],[\"763\",\"548\",\"广州\"],[\"764\",\"548\",\"韶关\"],[\"765\",\"548\",\"深圳\"],[\"766\",\"548\",\"珠海\"],[\"767\",\"548\",\"汕头\"],[\"768\",\"548\",\"佛山\"],[\"769\",\"548\",\"江门\"],[\"770\",\"548\",\"湛江\"],[\"771\",\"548\",\"茂名\"],[\"772\",\"548\",\"肇庆\"],[\"773\",\"548\",\"惠州\"],[\"774\",\"548\",\"梅州\"],[\"775\",\"548\",\"汕尾\"],[\"776\",\"548\",\"河源\"],[\"777\",\"548\",\"阳江\"],[\"778\",\"548\",\"清远\"],[\"779\",\"548\",\"东莞\"],[\"780\",\"548\",\"中山\"],[\"781\",\"548\",\"潮州\"],[\"782\",\"548\",\"揭阳\"],[\"783\",\"548\",\"云浮\"],[\"531\",\"489\",\"天津\"],[\"546\",\"489\",\"湖北\"],[\"736\",\"546\",\"武汉\"],[\"737\",\"546\",\"黄石\"],[\"738\",\"546\",\"十堰\"],[\"739\",\"546\",\"宜昌\"],[\"740\",\"546\",\"襄阳\"],[\"741\",\"546\",\"鄂州\"],[\"742\",\"546\",\"荆门\"],[\"743\",\"546\",\"孝感\"],[\"744\",\"546\",\"荆州\"],[\"745\",\"546\",\"黄冈\"],[\"746\",\"546\",\"咸宁\"],[\"747\",\"546\",\"随州\"],[\"748\",\"546\",\"恩施\"],[\"10057\",\"546\",\"公安\"],[\"10139\",\"546\",\"武穴\"],[\"10140\",\"546\",\"天门\"],[\"10168\",\"546\",\"仙桃\"],[\"10169\",\"546\",\"潜江\"],[\"10171\",\"546\",\"宜城\"],[\"10179\",\"546\",\"神农架\"],[\"556\",\"489\",\"陕西\"],[\"854\",\"556\",\"西安\"],[\"855\",\"556\",\"铜川\"],[\"856\",\"556\",\"宝鸡\"],[\"857\",\"556\",\"咸阳\"],[\"858\",\"556\",\"渭南\"],[\"859\",\"556\",\"延安\"],[\"860\",\"556\",\"汉中\"],[\"861\",\"556\",\"榆林\"],[\"862\",\"556\",\"安康\"],[\"863\",\"556\",\"商洛\"],[\"10058\",\"556\",\"兴平\"],[\"10470\",\"556\",\"杨凌\"],[\"933\",\"556\",\"西咸新区\"],[\"552\",\"489\",\"四川\"],[\"801\",\"552\",\"成都\"],[\"802\",\"552\",\"自贡\"],[\"803\",\"552\",\"攀枝花\"],[\"804\",\"552\",\"泸州\"],[\"805\",\"552\",\"德阳\"],[\"806\",\"552\",\"绵阳\"],[\"807\",\"552\",\"广元\"],[\"808\",\"552\",\"遂宁\"],[\"809\",\"552\",\"内江\"],[\"810\",\"552\",\"乐山\"],[\"811\",\"552\",\"南充\"],[\"812\",\"552\",\"眉山\"],[\"813\",\"552\",\"宜宾\"],[\"814\",\"552\",\"广安\"],[\"815\",\"552\",\"达州\"],[\"816\",\"552\",\"雅安\"],[\"817\",\"552\",\"巴中\"],[\"818\",\"552\",\"资阳\"],[\"819\",\"552\",\"阿坝\"],[\"820\",\"552\",\"甘孜\"],[\"821\",\"552\",\"凉山\"],[\"10065\",\"552\",\"峨眉\"],[\"10104\",\"552\",\"西昌\"],[\"10201\",\"552\",\"简阳\"],[\"535\",\"489\",\"辽宁\"],[\"600\",\"535\",\"大连\"],[\"599\",\"535\",\"沈阳\"],[\"601\",\"535\",\"鞍山\"],[\"602\",\"535\",\"抚顺\"],[\"603\",\"535\",\"本溪\"],[\"604\",\"535\",\"丹东\"],[\"605\",\"535\",\"锦州\"],[\"606\",\"535\",\"营口\"],[\"607\",\"535\",\"阜新\"],[\"608\",\"535\",\"辽阳\"],[\"609\",\"535\",\"盘锦\"],[\"610\",\"535\",\"铁岭\"],[\"611\",\"535\",\"朝阳\"],[\"612\",\"535\",\"葫芦岛\"],[\"10023\",\"535\",\"兴城\"],[\"10070\",\"535\",\"海城\"],[\"10080\",\"535\",\"昌图\"],[\"10144\",\"535\",\"开原\"],[\"931\",\"535\",\"东港\"],[\"536\",\"489\",\"吉林\"],[\"613\",\"536\",\"长春\"],[\"10198\",\"536\",\"珲春\"],[\"614\",\"536\",\"吉林市\"],[\"615\",\"536\",\"四平\"],[\"616\",\"536\",\"辽源\"],[\"617\",\"536\",\"通化\"],[\"618\",\"536\",\"白山\"],[\"619\",\"536\",\"松原\"],[\"620\",\"536\",\"白城\"],[\"621\",\"536\",\"延边\"],[\"10122\",\"536\",\"公主岭\"],[\"539\",\"489\",\"江苏\"],[\"635\",\"539\",\"南京\"],[\"639\",\"539\",\"苏州\"],[\"640\",\"539\",\"昆山\"],[\"650\",\"539\",\"常熟\"],[\"652\",\"539\",\"张家港\"],[\"636\",\"539\",\"无锡\"],[\"637\",\"539\",\"徐州\"],[\"638\",\"539\",\"常州\"],[\"641\",\"539\",\"南通\"],[\"642\",\"539\",\"连云港\"],[\"643\",\"539\",\"淮安\"],[\"644\",\"539\",\"盐城\"],[\"645\",\"539\",\"扬州\"],[\"646\",\"539\",\"镇江\"],[\"647\",\"539\",\"泰州\"],[\"648\",\"539\",\"宿迁\"],[\"911\",\"539\",\"太仓市\"],[\"544\",\"489\",\"山东\"],[\"702\",\"544\",\"济南\"],[\"703\",\"544\",\"青岛\"],[\"704\",\"544\",\"淄博\"],[\"705\",\"544\",\"枣庄\"],[\"706\",\"544\",\"东营\"],[\"707\",\"544\",\"烟台\"],[\"708\",\"544\",\"潍坊\"],[\"709\",\"544\",\"济宁\"],[\"710\",\"544\",\"泰安\"],[\"711\",\"544\",\"威海\"],[\"712\",\"544\",\"日照\"],[\"713\",\"544\",\"莱芜\"],[\"714\",\"544\",\"临沂\"],[\"715\",\"544\",\"德州\"],[\"716\",\"544\",\"聊城\"],[\"717\",\"544\",\"滨州\"],[\"718\",\"544\",\"菏泽\"],[\"540\",\"489\",\"浙江\"],[\"653\",\"540\",\"杭州\"],[\"654\",\"540\",\"宁波\"],[\"655\",\"540\",\"温州\"],[\"656\",\"540\",\"嘉兴\"],[\"657\",\"540\",\"湖州\"],[\"658\",\"540\",\"绍兴\"],[\"659\",\"540\",\"金华\"],[\"660\",\"540\",\"衢州\"],[\"661\",\"540\",\"舟山\"],[\"662\",\"540\",\"台州\"],[\"663\",\"540\",\"丽水\"],[\"10158\",\"540\",\"方家山\"],[\"549\",\"489\",\"广西\"],[\"785\",\"549\",\"南宁\"],[\"786\",\"549\",\"柳州\"],[\"787\",\"549\",\"桂林\"],[\"788\",\"549\",\"梧州\"],[\"789\",\"549\",\"北海\"],[\"790\",\"549\",\"防城港\"],[\"791\",\"549\",\"钦州\"],[\"792\",\"549\",\"贵港\"],[\"793\",\"549\",\"玉林\"],[\"794\",\"549\",\"百色\"],[\"795\",\"549\",\"贺州\"],[\"796\",\"549\",\"河池\"],[\"904\",\"549\",\"来宾\"],[\"905\",\"549\",\"崇左\"],[\"541\",\"489\",\"安徽\"],[\"664\",\"541\",\"合肥\"],[\"665\",\"541\",\"芜湖\"],[\"666\",\"541\",\"蚌埠\"],[\"667\",\"541\",\"淮南\"],[\"668\",\"541\",\"马鞍山\"],[\"669\",\"541\",\"淮北\"],[\"670\",\"541\",\"铜陵\"],[\"671\",\"541\",\"安庆\"],[\"672\",\"541\",\"黄山\"],[\"673\",\"541\",\"滁州\"],[\"674\",\"541\",\"阜阳\"],[\"675\",\"541\",\"宿州\"],[\"677\",\"541\",\"六安\"],[\"678\",\"541\",\"亳州\"],[\"679\",\"541\",\"池州\"],[\"680\",\"541\",\"宣城\"],[\"10069\",\"541\",\"凤阳\"],[\"10181\",\"541\",\"广德\"],[\"10182\",\"541\",\"宿松\"],[\"532\",\"489\",\"河北\"],[\"565\",\"532\",\"石家庄\"],[\"566\",\"532\",\"唐山\"],[\"567\",\"532\",\"秦皇岛\"],[\"568\",\"532\",\"邯郸\"],[\"569\",\"532\",\"邢台\"],[\"570\",\"532\",\"保定\"],[\"571\",\"532\",\"张家口\"],[\"572\",\"532\",\"承德\"],[\"573\",\"532\",\"沧州\"],[\"574\",\"532\",\"廊坊\"],[\"575\",\"532\",\"衡水\"],[\"10143\",\"532\",\"遵化\"],[\"533\",\"489\",\"山西\"],[\"576\",\"533\",\"太原\"],[\"577\",\"533\",\"大同\"],[\"578\",\"533\",\"阳泉\"],[\"579\",\"533\",\"长治\"],[\"580\",\"533\",\"晋城\"],[\"581\",\"533\",\"朔州\"],[\"582\",\"533\",\"晋中\"],[\"583\",\"533\",\"运城\"],[\"584\",\"533\",\"忻州\"],[\"585\",\"533\",\"临汾\"],[\"586\",\"533\",\"吕梁\"],[\"910\",\"533\",\"永济市\"],[\"534\",\"489\",\"内蒙古\"],[\"587\",\"534\",\"呼和浩特\"],[\"588\",\"534\",\"包头\"],[\"589\",\"534\",\"乌海\"],[\"590\",\"534\",\"赤峰\"],[\"591\",\"534\",\"通辽\"],[\"592\",\"534\",\"鄂尔多斯\"],[\"593\",\"534\",\"呼伦贝尔\"],[\"594\",\"534\",\"兴安盟\"],[\"595\",\"534\",\"锡林郭勒盟\"],[\"596\",\"534\",\"乌兰察布\"],[\"597\",\"534\",\"巴彦淖尔\"],[\"598\",\"534\",\"阿拉善盟\"],[\"10031\",\"534\",\"乌审旗\"],[\"10157\",\"534\",\"满洲里\"],[\"537\",\"489\",\"黑龙江\"],[\"622\",\"537\",\"哈尔滨\"],[\"623\",\"537\",\"齐齐哈尔\"],[\"624\",\"537\",\"鸡西\"],[\"625\",\"537\",\"鹤岗\"],[\"626\",\"537\",\"双鸭山\"],[\"627\",\"537\",\"大庆\"],[\"628\",\"537\",\"伊春\"],[\"629\",\"537\",\"佳木斯\"],[\"630\",\"537\",\"七台河\"],[\"631\",\"537\",\"牡丹江\"],[\"632\",\"537\",\"黑河\"],[\"633\",\"537\",\"绥化\"],[\"634\",\"537\",\"大兴安岭\"],[\"10081\",\"537\",\"安达\"],[\"10159\",\"537\",\"双城\"],[\"10160\",\"537\",\"尚志\"],[\"10161\",\"537\",\"绥芬河\"],[\"10510\",\"537\",\"肇东市\"],[\"542\",\"489\",\"福建\"],[\"681\",\"542\",\"福州\"],[\"682\",\"542\",\"厦门\"],[\"683\",\"542\",\"莆田\"],[\"684\",\"542\",\"三明\"],[\"685\",\"542\",\"泉州\"],[\"687\",\"542\",\"漳州\"],[\"688\",\"542\",\"南平\"],[\"689\",\"542\",\"龙岩\"],[\"690\",\"542\",\"宁德\"],[\"543\",\"489\",\"江西\"],[\"691\",\"543\",\"南昌\"],[\"692\",\"543\",\"景德镇\"],[\"693\",\"543\",\"萍乡\"],[\"694\",\"543\",\"九江\"],[\"695\",\"543\",\"新余\"],[\"696\",\"543\",\"鹰潭\"],[\"697\",\"543\",\"赣州\"],[\"698\",\"543\",\"吉安\"],[\"699\",\"543\",\"宜春\"],[\"700\",\"543\",\"抚州\"],[\"701\",\"543\",\"上饶\"],[\"545\",\"489\",\"河南\"],[\"719\",\"545\",\"郑州\"],[\"720\",\"545\",\"开封\"],[\"721\",\"545\",\"洛阳\"],[\"722\",\"545\",\"平顶山\"],[\"723\",\"545\",\"安阳\"],[\"724\",\"545\",\"鹤壁\"],[\"725\",\"545\",\"新乡\"],[\"726\",\"545\",\"焦作\"],[\"727\",\"545\",\"濮阳\"],[\"728\",\"545\",\"许昌\"],[\"729\",\"545\",\"漯河\"],[\"730\",\"545\",\"三门峡\"],[\"731\",\"545\",\"南阳\"],[\"732\",\"545\",\"商丘\"],[\"733\",\"545\",\"信阳\"],[\"734\",\"545\",\"周口\"],[\"735\",\"545\",\"驻马店\"],[\"10044\",\"545\",\"济源\"],[\"10059\",\"545\",\"西平\"],[\"547\",\"489\",\"湖南\"],[\"749\",\"547\",\"长沙\"],[\"750\",\"547\",\"株洲\"],[\"751\",\"547\",\"湘潭\"],[\"752\",\"547\",\"衡阳\"],[\"753\",\"547\",\"邵阳\"],[\"754\",\"547\",\"岳阳\"],[\"755\",\"547\",\"常德\"],[\"756\",\"547\",\"张家界\"],[\"757\",\"547\",\"益阳\"],[\"758\",\"547\",\"郴州\"],[\"759\",\"547\",\"永州\"],[\"760\",\"547\",\"怀化\"],[\"761\",\"547\",\"娄底\"],[\"762\",\"547\",\"湘西\"],[\"550\",\"489\",\"海南\"],[\"799\",\"550\",\"海口\"],[\"800\",\"550\",\"三亚\"],[\"907\",\"550\",\"洋浦市/洋浦经济开发区\"],[\"10153\",\"550\",\"琼海\"],[\"10183\",\"550\",\"儋州\"],[\"10184\",\"550\",\"五指山\"],[\"10185\",\"550\",\"文昌\"],[\"10186\",\"550\",\"万宁\"],[\"10187\",\"550\",\"东方\"],[\"10188\",\"550\",\"定安\"],[\"10189\",\"550\",\"屯昌\"],[\"10190\",\"550\",\"澄迈\"],[\"10191\",\"550\",\"临高\"],[\"10192\",\"550\",\"琼中\"],[\"10193\",\"550\",\"保亭\"],[\"10194\",\"550\",\"白沙\"],[\"10195\",\"550\",\"昌江\"],[\"10196\",\"550\",\"乐东\"],[\"10197\",\"550\",\"陵水\"],[\"551\",\"489\",\"重庆\"],[\"553\",\"489\",\"贵州\"],[\"822\",\"553\",\"贵阳\"],[\"823\",\"553\",\"六盘水\"],[\"824\",\"553\",\"遵义\"],[\"825\",\"553\",\"安顺\"],[\"826\",\"553\",\"铜仁\"],[\"827\",\"553\",\"黔西南\"],[\"828\",\"553\",\"毕节\"],[\"829\",\"553\",\"黔东南\"],[\"830\",\"553\",\"黔南\"],[\"554\",\"489\",\"云南\"],[\"831\",\"554\",\"昆明\"],[\"832\",\"554\",\"曲靖\"],[\"833\",\"554\",\"玉溪\"],[\"834\",\"554\",\"保山\"],[\"835\",\"554\",\"昭通\"],[\"836\",\"554\",\"楚雄\"],[\"837\",\"554\",\"红河\"],[\"838\",\"554\",\"文山\"],[\"840\",\"554\",\"西双版纳\"],[\"841\",\"554\",\"大理\"],[\"842\",\"554\",\"德宏\"],[\"843\",\"554\",\"丽江\"],[\"844\",\"554\",\"怒江\"],[\"845\",\"554\",\"迪庆\"],[\"846\",\"554\",\"临沧\"],[\"10163\",\"554\",\"普洱\"],[\"555\",\"489\",\"西藏\"],[\"847\",\"555\",\"拉萨\"],[\"848\",\"555\",\"昌都\"],[\"849\",\"555\",\"山南\"],[\"850\",\"555\",\"日喀则\"],[\"851\",\"555\",\"那曲\"],[\"852\",\"555\",\"阿里\"],[\"853\",\"555\",\"林芝\"],[\"557\",\"489\",\"甘肃\"],[\"864\",\"557\",\"兰州\"],[\"865\",\"557\",\"嘉峪关\"],[\"866\",\"557\",\"金昌\"],[\"867\",\"557\",\"白银\"],[\"868\",\"557\",\"天水\"],[\"869\",\"557\",\"武威\"],[\"870\",\"557\",\"张掖\"],[\"871\",\"557\",\"平凉\"],[\"872\",\"557\",\"酒泉\"],[\"873\",\"557\",\"庆阳\"],[\"874\",\"557\",\"定西\"],[\"875\",\"557\",\"陇南\"],[\"876\",\"557\",\"临夏\"],[\"877\",\"557\",\"甘南\"],[\"558\",\"489\",\"青海\"],[\"878\",\"558\",\"西宁\"],[\"879\",\"558\",\"海东\"],[\"880\",\"558\",\"海北\"],[\"881\",\"558\",\"黄南\"],[\"882\",\"558\",\"海南州\"],[\"883\",\"558\",\"果洛\"],[\"884\",\"558\",\"玉树\"],[\"885\",\"558\",\"海西\"],[\"559\",\"489\",\"宁夏\"],[\"886\",\"559\",\"银川\"],[\"887\",\"559\",\"石嘴山\"],[\"888\",\"559\",\"吴忠\"],[\"889\",\"559\",\"固原\"],[\"906\",\"559\",\"中卫\"],[\"560\",\"489\",\"新疆\"],[\"890\",\"560\",\"乌鲁木齐\"],[\"891\",\"560\",\"克拉玛依\"],[\"892\",\"560\",\"吐鲁番\"],[\"893\",\"560\",\"哈密\"],[\"894\",\"560\",\"昌吉\"],[\"895\",\"560\",\"博尔塔拉\"],[\"896\",\"560\",\"巴音郭楞\"],[\"897\",\"560\",\"阿克苏\"],[\"898\",\"560\",\"克孜勒苏\"],[\"899\",\"560\",\"喀什\"],[\"900\",\"560\",\"和田\"],[\"901\",\"560\",\"伊犁\"],[\"902\",\"560\",\"塔城\"],[\"903\",\"560\",\"阿勒泰\"],[\"10061\",\"560\",\"石河子\"],[\"10164\",\"560\",\"奎屯市\"],[\"10166\",\"560\",\"乌苏\"],[\"10176\",\"560\",\"阿拉尔\"],[\"10177\",\"560\",\"图木舒克\"],[\"10178\",\"560\",\"五家渠\"],[\"932\",\"560\",\"北屯市\"],[\"561\",\"489\",\"香港\"],[\"562\",\"489\",\"澳门\"],[\"563\",\"489\",\"台湾省\"],[\"480\",\"0\",\"国外\"],[\"481\",\"0\",\"阿根廷\"],[\"482\",\"0\",\"澳大利亚\"],[\"483\",\"0\",\"奥地利\"],[\"484\",\"0\",\"白俄罗斯\"],[\"485\",\"0\",\"比利时\"],[\"486\",\"0\",\"巴西\"],[\"487\",\"0\",\"保加利亚\"],[\"488\",\"0\",\"加拿大\"],[\"490\",\"0\",\"塞浦路斯\"],[\"491\",\"0\",\"捷克\"],[\"492\",\"0\",\"丹麦\"],[\"493\",\"0\",\"埃及\"],[\"494\",\"0\",\"芬兰\"],[\"495\",\"0\",\"法国\"],[\"496\",\"0\",\"德国\"],[\"497\",\"0\",\"希腊\"],[\"498\",\"0\",\"匈牙利\"],[\"499\",\"0\",\"冰岛\"],[\"500\",\"0\",\"印度\"],[\"501\",\"0\",\"印度尼西亚\"],[\"502\",\"0\",\"爱尔兰\"],[\"503\",\"0\",\"以色列\"],[\"504\",\"0\",\"意大利\"],[\"505\",\"0\",\"日本\"],[\"506\",\"0\",\"韩国\"],[\"507\",\"0\",\"科威特\"],[\"508\",\"0\",\"马来西亚\"],[\"509\",\"0\",\"荷兰\"],[\"510\",\"0\",\"新西兰\"],[\"511\",\"0\",\"挪威\"],[\"513\",\"0\",\"巴基斯坦\"],[\"514\",\"0\",\"波兰\"],[\"515\",\"0\",\"葡萄牙\"],[\"516\",\"0\",\"俄罗斯联邦\"],[\"517\",\"0\",\"沙特阿拉伯\"],[\"518\",\"0\",\"新加坡\"],[\"519\",\"0\",\"南非\"],[\"520\",\"0\",\"西班牙\"],[\"521\",\"0\",\"瑞典\"],[\"522\",\"0\",\"瑞士\"],[\"523\",\"0\",\"泰国\"],[\"524\",\"0\",\"土耳其\"],[\"525\",\"0\",\"乌克兰\"],[\"526\",\"0\",\"阿联酋\"],[\"527\",\"0\",\"英国\"],[\"528\",\"0\",\"美国\"],[\"529\",\"0\",\"越南\"],[\"913\",\"0\",\"安哥拉\"],[\"914\",\"0\",\"加纳\"],[\"915\",\"0\",\"尼日利亚\"],[\"916\",\"0\",\"坦桑尼亚\"],[\"917\",\"0\",\"乌干达\"],[\"918\",\"0\",\"阿尔及利亚\"],[\"919\",\"0\",\"塞内加尔\"],[\"930\",\"0\",\"柬埔寨\"],[\"512\",\"0\",\"其他\"]]}";
- }
对JSON格式的城市按照拼音首字母排序的更多相关文章
- mysql、oracle 中按照拼音首字母排序
mysql中按照拼音首字母排序 convert(name using gbk) ASC 注:name 为字段名称 oracle中按照拼音首字母排序 nlssort(enterprise_name,'N ...
- mysql 中将汉字(中文)按照拼音首字母排序
因为数据库中可以设定表的编码格式,不同编码格式下,中文的排序有区别,下面分别介绍常用编码下的排序方法. 1.如果数据表的某字段的字符编码是 utf8_general_ci,排序写法: ORDER BY ...
- sql语句按照汉字拼音首字母排序
oracle : 在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NLS_SORT值SCHINESE_RADICAL_M 按照部首(第一顺序).笔划(第二顺序)排序SCHINESE_STR ...
- mysql 中文字段排序( 按拼音首字母排序) 的查询语句
在处理使用Mysql时,数据表采用utf8字符集,使用中发现中文不能直接按照拼音排序 如果数据表tbl的某字段name的字符编码是latin1_swedish_ci select * from `tb ...
- MySQL按照汉字拼音首字母排序
按照汉字的拼音排序,用的比较多是在人名的排序中,按照姓氏的拼音字母,从A到Z排序: 如果存储姓名的字段采用的是GBK字符集,那就好办了,因为GBK内码编码时本身就采用了拼音排序的方法(常用一级汉字37 ...
- sql语句-按照汉字拼音首字母排序
在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NLS_SORT值 SCHINESE_RADICAL_M 按照部首(第一顺序).笔划(第二顺序)排序SCHINESE_STROKE_M 按照 ...
- mysql 中文字段排序( UTF8按拼音首字母排序)
select * from tableName CONVERT( FieldName USING gbk ) COLLATE gbk_chinese_ci desc
- MySQL字段值按照拼音首字母排序
最简单.快速的方法: 将需要进行排序的字段编码设置为GBK,然后在查询时直接使用asc/desc就可以啦
- javascript 实现中文按照拼音首字母排序
js提供了sort()方法来对数组内的数据进行排序,但是只是对英文有作用,这个时候需要自定义排序的规则 ['张三','李四','王五'].sort((a, b) => a.localeCompa ...
随机推荐
- Linux-配置虚拟IP
Linux下配置网卡ip别名何谓ip别名?用windows的话说,就是为一个网卡配置多个ip.什么场合增加ip别名能派上用场?布网需要.多ip访问测试.特定软件对多ip的需要...and so on. ...
- (原)ubuntu中安装tensorflow
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6592052.html 参考网址: https://www.tensorflow.org/install ...
- ILP32、ILP64、LP64、LLP64、64位系统
Data Type ILP32 ILP64 LP64 LLP64char 8 8 8 ...
- 记录EntityValidationErrors的详细信息
0.一个问题 使用过EF的人相信都会遇到Validation failed for one or more entities. See ‘EntityValidationErrors’这种异常,这是由 ...
- 【java】break outer,continue outer的使用
break默认是结束当前循环,有时我们在使用循环时,想通过内层循环里的语句直接跳出外层循环,java提供了使用break直接跳出外层循环,此时需要在break后通过标签指定外层循环.java中的标签是 ...
- formValidator输入验证、异步验证实例 + licenseImage验证码插件实例应用
实例技术:springmvc 实现功能:完整用户登录流程.输入信息规则校验.验证码异步校验. 功能清单: 1.springmvc控制器处理get请求(/member/login.html),进行静态页 ...
- Android基础之——CountDownTimer类,轻松实现倒计时功能
在发现这个类之前,一直是用的handler,子线程发消息,UI线程进行倒计时的显示工作.前几天在做一个倒计时显示的时候发现了这个类,用起来非常方便 翻看了下源代码.内部已经帮我们实现了handler的 ...
- ARGB和PARGB
原文链接: http://blog.csdn.net/lnwaycool/article/details/8610313 ARGB和PARGB是针对32位图像而言的,Windows下图像可以是1位.4 ...
- [转]SSH 原理和基本使用:ssh 安全配置 以及ssh key 认证登录
一.什么是 SSH ? SSH全称(Secure SHell)是一种网络协议,顾名思义就是非常安全的shell,主要用于计算机间加密传输.早期,互联网通信都是基于明文通信,一旦被截获,内容就暴露无遗. ...
- 转 kafka架构简介
kafka架构 转 http://www.cnblogs.com/chushiyaoyue/p/5612298.html 相关文章: https://www.jianshu.com/p/6233d53 ...